#include<stdio.h>
#include<string.h>
#include<algorithm>
using namespace std;
struct point
{
int x,y,z;
int area;
}b[200];
bool compare(point c,point d){ return c.area<d.area;}
int cmp(point c,point d){
if((c.x>d.x && c.y>d.y)||(c.x>d.y && c.y>d.x))
return 1;
else
return 0;
}
int main()
{
int a[4],dir[3][3]={{0,1,2},{1,2,0},{0,2,1}},n,i,j,num,sum[200],m=0;
while(scanf("%d",&n) , n){
num=0;
memset(sum,0,sizeof(sum));
for(i=0;i<n;i++){
scanf("%d%d%d",&a[0],&a[1],&a[2]);
for(j=0;j<3;j++){
b[num].x=a[dir[j][0]];
b[num].y=a[dir[j][1]];
b[num].z=a[dir[j][2]];
b[num].area=b[num].x*b[num].y;
num++;
}
}
sort(b,b+num,compare);
sum[0]=b[0].y;
for(i=0;i<3*n;i++){
int temp=0;
for(j=0;j<i;j++){
if(sum[j]>temp && cmp(b[i],b[j])){
temp=sum[j];
}
}
sum[i]=temp+b[i].z;
}
int max=-1;
for(i=0;i<3*n;i++)
if(max<sum[i])
max=sum[i];
printf("Case %d: maximum height = %d\n",++m,max);
}
return 0;
}
hdu1069 Monkey and Banana DP 最大不降子序列的扩展
最新推荐文章于 2022-02-25 19:38:17 发布