Test instructions
The given box (not limited to) superimposed together, the condition is that the upper box is longer and wider than the box below the length and width of the short;
The maximum height at which these boxes can be superimposed (3,2,1) can be placed (3,1,2), (2,1,3), etc.).
/************************************************author:d evilcreated TIME:2015/12/7 20:38:42***************** ******************************* */#include<iostream>#include<algorithm>#include<cstring>#include<cmath>#include<queue>#include<map>#include<Set>#include<vector>#include<cstdio>using namespacestd;structwq{intA,b,c;} p[ -];intdp[ -],cnt;voidAddintXintYintz) {P[CNT].A=x; P[CNT].B=y; P[cnt++].c=Z;}BOOLCMP (Wq a,wq b) {if(A.A!=B.A)returnA.a>B.A; returnA.b>b.b;}intMain () {//freopen ("In.txt", "R", stdin); intn,x,y,z,cas=1; while(~SCANF ("%d", &n) &&N) {cnt=0; for(intI=0; i<n; i++) {scanf ("%d%d%d",&x,&y,&z); if(x>y) Swap (x, y); if(x>z) swap (x,z); if(y>z) swap (y,z); Add (x, y, z); Add (y,z,x); Add (x,z,y); } sort (P,p+cnt,cmp); dp[0]=p[0].c; intans=dp[0]; for(intI=1; i<cnt;i++) {Dp[i]=p[i].c; for(intj=0; j<i;j++) if(p[i].a<p[j].a&&p[i].b<p[j].b) Dp[i]=max (dp[i],dp[j]+p[i].c); Ans=Max (ans,dp[i]); } printf ("Case %d:maximum height =%d\n", cas++, ans); } return 0;}
HDU1069 Monkey and Banana simple DP