the override operator is just a guess...
/* UVas */ /*****************************************************************************/ struct block { int x, y, h; inline bool operator<(const block &o) const { if (x==o.x) return y<o.y; return x<o.x; } } b[180]; int n, ce=1; int d[180]; int main(void) { while (scanf("%d", &n)>0&&n) { for (int i=0; i<n; i++) { int x, y, z; scanf("%d %d %d", &x, &y, &z); b[i*6].x=x, b[i*6].y=y, b[i*6].h=z; b[i*6+1].x=x, b[i*6+1].y=z, b[i*6+1].h=y; b[i*6+2].x=y, b[i*6+2].y=x, b[i*6+2].h=z; b[i*6+3].x=y, b[i*6+3].y=z, b[i*6+3].h=x; b[i*6+4].x=z, b[i*6+4].y=x, b[i*6+4].h=y; b[i*6+5].x=z, b[i*6+5].y=y, b[i*6+5].h=x; } sort(b, b+6*n); int r=0; d[0]=b[0].h; for (int i=1; i<6*n; i++) { d[i]=b[i].h; for (int j=0; j<i; j++) if (b[j].x<b[i].x&&b[j].y<b[i].y&&d[j]+b[i].h>d[i]) d[i]=d[j]+b[i].h; r=max(r, d[i]); } printf("Case %d: maximum height = %d\n", ce++, r); } } /*****************************************************************************/
No comments :
Post a Comment