Pagini recente » Cod sursa (job #140039) | Cod sursa (job #1741419) | Cod sursa (job #910381) | Cod sursa (job #734794) | Cod sursa (job #2497830)
#include <cstdio>
#define maxLength 128*1024
#define max2Length 256*1024
using namespace std;
int takeMax(int x,int y) {
return (x>y)*(x-y)+y;
}
int takeBiggerP2(int x) {
int sol;
for(sol=1;sol<=x;sol<<=1) {
}
return sol>>1;
}
class Xxx {
public:
int length,lp2;
int v[max2Length];
Xxx();
Xxx(int newLength,int newElements[]);
int takeParent(int l2,int pos);
int takeChild1(int l2,int pos);
int takeChild2(int l2,int pos);
void update(int l2,int pos);
void update(int l2,int pos,int value);
int maxp(int pow2,int pos1,int pos2);
};
Xxx::Xxx() {
}
Xxx::Xxx(int newLength,int newElements[]) {
int i,k,p2;
for(i=0;i<newLength/p02;++i) {
v[i]=newElements[i];
}
length=newLentgh;
for(k=lp2=takeBiggerP2(newLength),p2=lp2;p2;p2>>=1,k+=p2) {
for(i=0;i<p2;++i) {
v[k+i]=max(v[k-p2+i<<1],v[k-p2+i<<1+1]);
}
}
}
int Xxx::takeParent(int l2,int x) {
return l2+x>>1;
}
int Xxx::takeChild1(int l2,int x) {
return l2<<1+;
}
int Xxx::takeChild2(int l2,int x) {
return l2+x>>1;
}
void Xxx::update(int l2,int pos) {
update(l2>>1,takeParent(l2,pos));
}
void Xxx::update(int l2,int pos,int value) {
int ;
}
int main()
{
freopen("arbint.in","r",stdin);
freopen("arbint.out","w",stdout);
return 0;
}