## 细语呢喃

www.hrwhisper.me 新blog

# HDU 1069 Monkey and Banana DP LIS

http://acm.hdu.edu.cn/showproblem.php?pid=1069

#include<cstdio>
#include<algorithm>
using namespace std;
const int MAXN=200;
struct data
{
int x,y;
int h;
}a[MAXN];
bool operator <(const data &a,const data &b)
{
return a.x<b.x;
}
int main()
{
int n;
int kase=1;
while(scanf("%d",&n),n)
{
int len=0;
int x,y,z;
for(int i=0;i<n;i++)
{
scanf("%d%d%d",&x,&y,&z);
a[len].x=x;    a[len].y=y;     a[len++].h=z;
a[len].x=x;    a[len].y=z;     a[len++].h=y;
a[len].x=y;    a[len].y=x;     a[len++].h=z;
a[len].x=y;    a[len].y=z;     a[len++].h=x;
a[len].x=z;    a[len].y=x;     a[len++].h=y;
a[len].x=z;    a[len].y=y;     a[len++].h=x;
}

sort(a,a+len);

int dp[MAXN];
for(int i=0;i<len;i++)
{
dp[i]=a[i].h;
int temp=0;
for(int j=0;j<i;j++)
{
if(a[i].x>a[j].x && a[i].y >a[j].y)
temp=max(temp,dp[j]);
}
dp[i]+=temp;
}
int ans=0;
for(int i=0;i<len;i++)
ans=max(ans,dp[i]);

printf("Case %d: maximum height = %d\n",kase++,ans);
}

return 0;
}

#### HDU 1069 Monkey and Banana(DP)

2016-03-03 19:13:06

#### HDU 1069 Monkey and Banana (LIS)

2018-02-01 17:50:53

#### HDU 1069 Monkey and Banana(dp)

2014-03-29 18:35:20

#### HDU 1069 Monkey and Banana (dp)

2017-07-15 21:23:53

#### hdu 1069 Monkey and Banana(dp)

2015-03-20 15:00:14

#### ACM-经典DP之Monkey and Banana——hdu1069

2014-05-22 17:26:02

#### HDU 1069 Monkey and Banana（最大的单调递减序列啊 dp）

2015-07-16 19:22:04

#### HDU1069 Monkey and Banana （动态规划）

2017-02-05 17:21:32

#### hdu -1069 Monkey and Banana【贪心+dp】

2016-03-07 21:07:23

#### HDU-1069-Monkey and Banana【DP】

2016-08-09 16:50:24