Topic:
First, by limiting the height from small to large sort, will not affect the feasible solution, but not the sorting may be the correct situation;
When scrolling an array with%2, be sure to pay attention to each copy of the situation, because this WA several times.
The code is as follows:
#include <iostream>#include<cstdio>#include<algorithm>#include<cstring>using namespacestd;intk,mx;BOOLf[3][400005];structn{intH,a,c;} p[405];BOOLCMP (N x,n y) {returnx.a<y.a;}intMain () {scanf ("%d",&k); for(intI=1; i<=k;i++) scanf ("%d%d%d", &p[i].h,&p[i].a,&p[i].c), mx+=p[i].h*p[i].c; Sort (P+1, p+k+1, CMP); f[0][0]=1; for(intI=1; i<=k;i++) {memcpy (f[i%2],f[(I-1)%2],sizeoff[(I-1)%2]);//!!! for(intj=p[i].h;j<=p[i].a;j++) for(intL=0; l<=p[i].c&&j-l*p[i].h>=0; l++) if(F[(i1)%2][j-l*p[i].h]) f[i%2][j]=1; } for(intj=mx;j>=0; j--) if(f[k%2][j]) {printf ("%d", J); return 0; }}
poj2392 Stone--Sort after backpack