#include<iostream>#include<algorithm>using namespace std;struct block{ int x,y,z;}b[100];int max(int a,int b){ return a>b?a:b;}int min(int a,int b){ return a>b?b:a;}bool cmp(block &a,block &b){ return a.x>b.x?true:false;}int main(){ int n,x,y,z,i,j,k=0,ans,maxs,kk=0; while(cin>>n&&n!=0) { maxs=0; kk++; k=0; for(i=0;i<n;i++) { cin>>x>>y>>z; b[k].x=max(x,y);b[k].y=min(x,y);b[k++].z=z; b[k].x=max(x,z);b[k].y=min(x,z);b[k++].z=y; b[k].x=max(y,z);b[k].y=min(y,z);b[k++].z=x; } sort(b,b+3*n,cmp); for(i=3*n-2;i>=0;i--) { ans=0; for(j=i+1;j<3*n;j++) if(b[j].x<b[i].x&&b[j].y<b[i].y&&b[j].z>ans)ans=b[j].z; b[i].z+=ans; if(b[i].z>maxs) maxs=b[i].z; } cout<<"Case "<<kk<<": maximum height = "<<maxs<<endl; } return 0;}
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)