hdu 1069 (DP) Monkey and Banana
题目:这里
题意:
Description
Input
Output
Sample Input
2
6 8 10
5 5 5
7
1 1 1
2 2 2
3 3 3
4 4 4
5 5 5
6 6 6
7 7 7
5
31 41 59
26 53 58
97 93 23
84 62 64
33 83 27
0
Sample Output
Case 3: maximum height = 28
Case 4: maximum height = 342
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<cmath>
#include<string>
using namespace std; struct node{
int h,v,l;
}re[];
int dp[]; int max(int x,int y) {return x>y?x:y;} bool cmp(node a,node b)
{
if (a.l==b.l)
{
if (a.v==b.v)
return a.h>b.h;
return a.v>b.v;
}
return a.l>b.l;
} int main()
{
int n,tem=;
while (~scanf("%d",&n)&&n)
{
int cas=;
for (int i= ; i<=n ; i++)
{
int x,y,z;
scanf("%d%d%d",&x,&y,&z);
re[++cas].l=x,re[cas].h=y,re[cas].v=z;
re[++cas].l=z,re[cas].h=y,re[cas].v=x;
re[++cas].l=x,re[cas].h=z,re[cas].v=y;
re[++cas].l=y,re[cas].h=z,re[cas].v=x;
re[++cas].l=z,re[cas].h=x,re[cas].v=y;
re[++cas].l=y,re[cas].h=x,re[cas].v=z;
}
sort(re+,re+cas+,cmp);
for (int i= ; i<=cas ; i++)
{
dp[i]=re[i].h;
for (int j= ; j<i ; j++)
{
if (re[i].l<re[j].l&&re[i].v<re[j].v)
dp[i]=max(dp[i],dp[j]+re[i].h);
}
}
int ans=;
for (int i= ; i<=cas ; i++)
ans=max(ans,dp[i]);
printf("Case %d: maximum height = %d\n",++tem,ans);
}
return ;
}
hdu 1069 (DP) Monkey and Banana的更多相关文章
- HDU 1069:Monkey and Banana(DP)
Monkey and Banana Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others ...
- 【HDU - 1069】 Monkey and Banana (基础dp)
Monkey and Banana 直接写中文了 Problem Statement 一组研究人员正在设计一项实验,以测试猴子的智商.他们将挂香蕉在建筑物的屋顶,同时,提供一些砖块给这些猴子.如果猴子 ...
- HDU 1069 dp最长递增子序列
B - Monkey and Banana Time Limit:1000MS Memory Limit:32768KB 64bit IO Format:%I64d & %I6 ...
- HDU 1069---背包---Monkey and Banana
HDU 1069 Description A group of researchers are designing an experiment to test the IQ of a monkey. ...
- HDU 1069 Monkey and Banana (DP)
Monkey and Banana Time Limit:1000MS Memory Limit:32768KB 64bit IO Format:%I64d & %I64u S ...
- HDU 1069—— Monkey and Banana——————【dp】
Monkey and Banana Time Limit:1000MS Memory Limit:32768KB 64bit IO Format:%I64d & %I64u S ...
- HDU 1069 Monkey and Banana dp 题解
HDU 1069 Monkey and Banana 纵有疾风起 题目大意 一堆科学家研究猩猩的智商,给他M种长方体,每种N个.然后,将一个香蕉挂在屋顶,让猩猩通过 叠长方体来够到香蕉. 现在给你M种 ...
- HDU 1069 Monkey and Banana(DP 长方体堆放问题)
Monkey and Banana Problem Description A group of researchers are designing an experiment to test the ...
- HDU 1069 Monkey and Banana 基础DP
题目链接:Monkey and Banana 大意:给出n种箱子的长宽高.每种不限个数.可以堆叠.询问可以达到的最高高度是多少. 要求两个箱子堆叠的时候叠加的面.上面的面的两维长度都严格小于下面的. ...
随机推荐
- 显示全部select change 异常
异常信息(异常类型:Genersoft.Platform.Core.Error.GSPException)异常提示:调用方法SelectChange发生异常,详细请看内部异常信息!异常信息:调用方法S ...
- Media Queries详解
Media Queries直译过来就是“媒体查询”,在我们平时的Web页面中head部分常看到这样的一段代码: <link href="css/reset.css" rel ...
- css secrets----multiple borders
原始文档: https://www.zybuluo.com/freeethy/note/193574 box-shadow solution 只能实现solid border box-shadow表现 ...
- linux(Debian) 中的cron计划任务配置方法
cron服务每分钟不仅要读一次/var/spool/cron内的所有文件,还需要读一次/etc/crontab,因此我们配置这个文件也能运用cron服务做一些事情.用crontab配置是针对某个用户的 ...
- jquery 高度的获取
alert($(window).height()); //浏览器当前窗口可视区域高度 alert($(document).height()); //浏览器当前窗口文档的高度 alert($(docum ...
- STL迭代器之二:迭代器型别
如果一个迭代器要兼容stl,必须遵循约定,自行以内嵌型别定义的方式定义出相应型别.根据书中介绍,最常用到的迭代器型别有五种:value type,difference type, pointer, r ...
- elasticsearch中常用的API
elasticsearch中常用的API分类如下: 文档API: 提供对文档的增删改查操作 搜索API: 提供对文档进行某个字段的查询 索引API: 提供对索引进行操作,查看索引信息等 查看API: ...
- 用浏览器模拟各种User Agent
转至:http://www.cnblogs.com/top5/archive/2012/06/07/2540686.html 测试页面的时候经常需要不同的User Agent,Firefox.Chro ...
- JDK&JRE&JVM
JDK:—Java Development kit (Java开发工具包) JRE:—Java Runtime Environment (Java运行时环境) JVM:Java Virtual Ma ...
- Java日志——2016年5月30日
1. 局部变量必须初始化,可以定义的同时初始化,也可以定义完成之后进行初始化. 2. Java7新特性:数字之间可以使用"_"连接,eg:23_44_5 = 23445,0B110 ...