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

题目大意

一群研究员在研究猴子的智商(T T禽兽啊,欺负猴子!!!),他们决定在房顶放一串香蕉,并且给猴子n种砖块。

砖块长宽高分别为xyz,每一种可以取任意个,并且他们可以随意的摆放。

然后要求堆叠起来的砖块上面的必须严格小于下面的。

求最大可以堆叠的高度。

思路:

转化为LIS问题,把每一种摆放方法如(10,20,30)(可以以20 30 作为底,10作为高)都放进数组,然后就是求最大上升子序列。

#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 LIS的更多相关文章

  1. HDU 1069 Monkey and Banana DP LIS变形题

    http://acm.hdu.edu.cn/showproblem.php?pid=1069 意思就是给定n种箱子,每种箱子都有无限个,每种箱子都是有三个参数(x, y, z)来确定. 你可以选任意两 ...

  2. HDU 1069 monkey an banana DP LIS

    Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64uDescription 一组研究人员正在 ...

  3. HDU 1069 Monkey and Banana dp 题解

    HDU 1069 Monkey and Banana 纵有疾风起 题目大意 一堆科学家研究猩猩的智商,给他M种长方体,每种N个.然后,将一个香蕉挂在屋顶,让猩猩通过 叠长方体来够到香蕉. 现在给你M种 ...

  4. HDU 1069 Monkey and Banana (DP)

    Monkey and Banana Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u S ...

  5. HDU 1069 Monkey and Banana(DP 长方体堆放问题)

    Monkey and Banana Problem Description A group of researchers are designing an experiment to test the ...

  6. HDU 1069 Monkey and Banana(LIS最长上升子序列)

    B - LIS Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u   Descripti ...

  7. hdu(1069)——Monkey and Banana(LIS变形)

    题意: 如今给你n个石块,然后它由坐标来表示(x,y,z).可是它能够有不同的方法,也就是说它的三个坐标能够轮换着来的. 石块的数量不限,可是每次都必须保持上底面的长和宽严格递减,然后问你用这些石块所 ...

  8. HDU 1069 Monkey and Banana / ZOJ 1093 Monkey and Banana (最长路径)

    HDU 1069 Monkey and Banana / ZOJ 1093 Monkey and Banana (最长路径) Description A group of researchers ar ...

  9. HDU 1069 Monkey and Banana(转换成LIS,做法很值得学习)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1069 Monkey and Banana Time Limit: 2000/1000 MS (Java ...

随机推荐

  1. [Redux-Observable && Unit Testing] Mocking an ajax request when testing epics

    Often in unit tests we are focussing on the logic involved in crafting a network request, & how ...

  2. 从”茄子快传”看应用程序怎样获取手机已安装程序的apk文件

    "茄子快传"是联想开发的一款近距离文件共享软件.它通过wifi-direct(速度飞快,不须要联网)或者普通的网络(速度慢)在不同手机间传递文件. 不知为何.它就火了起来,火的也飞 ...

  3. 阿里云 django的一次web维护记录

    首先, 丢给我一个阿里云的server的账号/password,之前没有玩过阿里云,想想应该也是ssh服务来远程登陆. 环境: centos+nginx+uwsgi+python2.7+django. ...

  4. hdoj 2122 Ice_cream’s world III【最小生成树】

    Ice_cream's world III Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Ot ...

  5. Windows平台上的pip安装

    写在前面 pip 是 Python 的包管理工具,在 Python 开发中必不可少.作为一名python菜鸟,本文在踩坑无数的基础上尽可能详细地解释pip的安装过程.在安装之前需要明确两点: 1.pi ...

  6. 洛谷 P1916 小书童——蚂蚁大战

    P1916 小书童——蚂蚁大战 题目背景 小A在你的帮助下,开始“刷题”,他在小书童里发现了一款叫“蚂蚁大战”(又称蛋糕保卫战)的游戏.(你懂得) 题目描述 游戏中会出现n只蚂蚁,分别有a1,a2…… ...

  7. ASP.Net MVC Filter验证用户登录

    一.Filter是什么 ASP.NetMVC模式自带的过滤器Filter,是一种声明式编程方式,支持四种过滤器类型,各自是:Authorization(授权),Action(行为),Result(结果 ...

  8. 早该知道的 7 个JavaScript 技巧[转]

    简洁写法 对象的简写在过去,如果你想创建一个对象,你需要这样: var car = new Object();  car.colour = 'red';  car.wheels = 4;  car.h ...

  9. Java – Reading a Large File Efficiently--转

    原文地址:http://www.baeldung.com/java-read-lines-large-file 1. Overview This tutorial will show how to r ...

  10. ASP.NET MVC案例教程(基于ASP.NET MVC beta)——第三篇:ASP.NET MVC全局观

    摘要      本文对ASP.NET MVC的全局运行机理进行一个简要的介绍,以使得朋友们更好的理解后续文章. 前言      在上一篇文章中,我们实现了第一个ASP.NET MVC页面.对于没有接触 ...