标签:
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 (最长上升子序列)
标签:
原文地址:http://www.cnblogs.com/sola1994/p/4322176.html