http://acm.hdu.edu.cn/showproblem.php?pid=1069
#include <cstdio> #include <cstring> #include <iostream> #include <algorithm>using namespace std;struct node{int a,b,c,dp;}; Node Node[3000];int CMP (node X,node y) {if (X.A==Y.A) return x.b<y.b; return x.a<y.a;} int main () {int n; int i,j,k; int a,b,c; int Cas=1; while (scanf ("%d", &n), N) {for (i=1;i<=6*n;i++) {scanf ("%d%d%d", &a,&b,&c); node[i].a=a;node[i].b=b;node[i].dp=node[i].c=c;i++; node[i].a=a;node[i].b=c;node[i].dp=node[i].c=b;i++; node[i].a=b;node[i].b=a;node[i].dp=node[i].c=c;i++; node[i].a=b;node[i].b=c;node[i].dp=node[i].c=a;i++; node[i].a=c;node[i].b=a;node[i].dp=node[i].c=b;i++; Node[i].a=c;node[i].b=b;node[i].dp=node[i].c=a; } sort (node+1,node+6*n+1,cmp); int maxx=node[6*n].c; for (i=6*n-1;i>=1;i--) {for (j=i+1;j<=6*n;j++) {if (node[i].a<node[j].a&&node[i].b< NODE[J].B&&NODE[I].DP<NODE[I].C+NODE[J].DP) Node[i].dp=noDE[I].C+NODE[J].DP; } if (Node[i].dp>maxx) MAXX=NODE[I].DP; }/*printf ("ssssssssssssssssss\n"); for (i=1;i<=6*n;i++) {printf ("%d%d%d%d\n", NODE[I].A,NODE[I].B,NODE[I].C,NODE[I].DP); }*/printf ("Case%d:maximum height =%d\n", Cas++,maxx); } return 0;}
HDU 1069 Monkey and Banana (longest ascending subsequence)