hdu 1069 Monkey and Banana//DP

#include"iostream"
#include"stdio.h"
#include"algorithm"
using namespace std;
#define MAXN 32
struct NODE
{
int l,w,h,s;
}node[MAXN*3];
int dp[MAXN*3];
bool cmp(NODE a,NODE b)
{
return a.l*a.w>b.l*b.w;
}
bool check (int i,int j)
{
if(node[i].l
return true;
if(node[i].l
return true;
return false;
}
int main()
{
int n,count=1,i,j;
while(scanf("%d",&n) && n!=0)
{
int x,y,z;
for(i=0;i
{
scanf("%d%d%d",&x,&y,&z);
node[3*i].l   = x; node[3*i].w   = y; node[3*i].h   = z;
node[3*i+1].l = y; node[3*i+1].w = z; node[3*i+1].h = x;
node[3*i+2].l = x; node[3*i+2].w = z; node[3*i+2].h = y;
}
sort(node,node+3*n,cmp);
dp[0]=node[0].h;
for(i=1;i<3*n;i++)
{
int max=0;
for(j=0;j
if(max
max=dp[j];
dp[i]=max+node[i].h;//key point
    }
   
   
int ans=dp[0];
for(i=1;i<3*n;i++)
{
if(ans
ans=dp[i];
}
printf("Case %d: maximum height = %d\n",count++,ans);
}
    getchar();getchar();
    return 0;
}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值