#include<iostream>
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<cmath>
#define N 40
using namespace std;
struct node
{
int x,y,z;
node(){}
node(int x,int y,int z):x(x),y(y),z(z)
{}
bool operator < (const node b)const
{
if(x==b.x)
{
return y>b.y;
}
else
return x>b.x;
}
}a[N*3];
int tot=0;
void addnode(int x,int y,int z)
{
a[tot++]=node(min(x,y),max(x,y),z);
a[tot++]=node(min(x,z),max(x,z),y);
a[tot++]=node(min(y,z),max(y,z),x);
}
int dp[N*3];
bool ok(node p,node q)
{
if(p.x>q.x&&p.y>q.y)
return true;
return false;
}
int main()
{
int n,i,j,x,y,z;
int ca=0;
int ma,ans;
while(scanf("%d",&n))
{
ca++;
if(n==0)break;
memset(dp,0,sizeof(dp));
tot=0;
for(i=0;i<n;i++)
{
scanf("%d%d%d",&x,&y,&z);
addnode(x,y,z);
}
sort(a,a+tot);
dp[0]=a[0].z;
ans=a[0].z;
for(i=1;i<tot;i++)
{
ma=0;
for(j=0;j<i;j++)
if(ok(a[j],a[i]))
ma=max(ma,dp[j]);
dp[i]=ma+a[i].z;
ans=max(ans,dp[i]);
}
printf("Case %d: maximum height = %d\n",ca,ans);
}
}
hdu1069
最新推荐文章于 2023-02-23 21:49:54 发布