#include <cstdio>
#include <cstring>
#include <queue>
#include <iostream>
#include <algorithm>
using namespace std;
const int N=200;
int dp[N];
struct node{
int x,y,z;
node() {}
node(int a, int b, int c): x(a), y(b), z(c) {}
bool operator > (node &other) const
{
return (x>other.x && y>other.y);
}
}v[N];
bool cmp(const node &a, const node &b){
return ( a.x>b.x || (a.x==b.x && a.y>b.y) );
}
int main()
{
// freopen("in","r",stdin);
// freopen("out","w",stdout);
int i,j,a,b,c,n,m,ans,th=1;
while( scanf("%d",&n) && n )
{
memset(dp,0,sizeof(dp));
for(i=m=0;i<n;i++)
{
scanf("%d%d%d",&a,&b,&c);
v[m]=node(a,b,c);
v[m+1]=node(a,c,b);
v[m+2]=node(b,c,a);
v[m+3]=node(c,a,b);
v[m+4]=node(b,a,c);
v[m+5]=node(c,b,a);
m+=6;
}
sort(v,v+m,cmp);
for(i=0;i<m;i++) dp[i]=v[i].z;
for(i=0;i<m;i++)
for(j=0;j<m;j++){
if(v[i]>v[j])
dp[j]=max(dp[j],dp[i]+v[j].z);
}
ans=0;
for(i=0;i<m;i++)
ans=max(ans,dp[i]);
printf("Case %d: maximum height = %d\n",th++,ans);
}
return 0;
}
hdu 1069
最新推荐文章于 2022-11-24 17:48:20 发布