#include #include #define size 524288//64 #define dvd 26//3 long long llmax(long long a,long long b){if(a>b){return a;}return b;} typedef struct{ long long score; long long cost; }sd; int sdsortfncsj(const void *a,const void *b){ if(((sd*)a)->cost < ((sd*)b)->cost){return -1;} if(((sd*)a)->cost > ((sd*)b)->cost){return 1;} return 0; } int sdsortfnckj(const void *a,const void *b){ if(((sd*)a)->cost > ((sd*)b)->cost){return -1;} if(((sd*)a)->cost < ((sd*)b)->cost){return 1;} return 0; } int main(){ long long i,j,c=0,fl,w,res=0; long long fmem[size]; sd fir[2][size],sec[2][size],cd; //fir[1...last==school] sec[1...first==school] //merge pattern : 1+0 0+1 0+0 long long fc[2]={0},sc[2]={0}; long long p[64]={0},q[64]={0},r[64]={0}; long long fp,sp; scanf("%lld",&w); for(i=0;i=0;j--){ if((i&(1ll<<(j+1)))!=0 && (i&(1ll<\n",fir[i][j].cost,fir[i][j].score);} qsort(sec[i],sc[i],sizeof(sec[i][0]),sdsortfnckj); for(j=sc[i]-2;j>=0;j--){ sec[i][j].score=llmax(sec[i][j+1].score,sec[i][j].score); } //for(j=0;j\n",sec[i][j].cost,sec[i][j].score);} } //fprintf(stderr,"ok\n"); fp=0;sp=0; while(fp