标签:
Monkey and Banana
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 6866 Accepted Submission(s): 3516
#include<iostream> #include<cstdio> #include<cstring> #include<cstdlib> #include<algorithm> using namespace std; #define N 220 struct node { int x,y,z,v,h; }; int cmp(node a,node b) { return a.v<b.v; } int main() { int i,j,x,y,z,n,t=0; node a[N]; while(scanf("%d",&n),n) { memset(a,0,sizeof(a)); j=0; for(i=0;i<n;i++) { scanf("%d %d %d",&x,&y,&z); a[j].x=x;a[j].y=y;a[j].z=z;a[j].v=x*y;j++; a[j].x=y;a[j].y=z;a[j].z=x;a[j].v=y*z;j++; a[j].x=z;a[j].y=x;a[j].z=y;a[j].v=x*z;j++; } sort(a,a+j,cmp); for(i=0;i<n*3;i++) { int MAX=0; for(j=0;j<i;j++) { if(((a[i].x>a[j].y&&a[i].y>a[j].x)||(a[i].x>a[j].x&&a[i].y>a[j].y))&&a[j].h>MAX) { MAX=a[j].h; } } a[i].h=a[i].z+MAX; } int ans=0; for(i=0;i<3*n;i++) { ans=max(ans,a[i].h); } t++; printf("Case %d: maximum height = %d\n",t,ans); } return 0; }
标签:
原文地址:http://www.cnblogs.com/zhengguiping--9876/p/4477212.html