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种箱子的长宽高.每种不限个数.可以堆叠.询问可以达到的最高高度是多少. 要求两个箱子堆叠的时候叠加的面.上面的面的两维长度都严格小于下面的. ...
随机推荐
- git&sourcetree安装及在IntelliIJ下拉取项目基础使用
be careful: 1)git版本与Sourcetree版本最好一致 ,不能git为2.5,sourcetree为1.8 2)先安装git再安装Sourcetree 3)拥有git和sourcet ...
- php-fpm 在centos 7下的安装配置
安装php: sudo yum install php php-fpm php-mysql php-mbstring php-mcrypt php-sockets php-curl php-commo ...
- 老生长谈,温故知新:css实现右侧固定宽度,左侧宽度自适应
反过来也可以:左侧宽度固定,右侧自适应.不管是左是右,反正就是一边宽度固定,一边宽度自适应. 这种布局比较常见,博客园很多默认主题就是这种.一般情况下,这种布局中宽度固定的区域是侧边栏,而自适应的区域 ...
- 使用Birt开发报表
间隔一段时间未使用Birt开发报表后,本文章记录Birt开发报表的常遇到的开发问题及解决措施,方便自己和园内其他朋友学习. 一.Birt连接数据库配置 1.连接DB2数据库: 1.1.birt的数据连 ...
- mongodb 分组查询
数据的保存 include_once 'mDB.class.php'; $m=new mDB(); $m->setDB('mydb'); // $m->save('stu',['dept' ...
- 一个C#语法高亮插件
语法高亮对程序员阅读代码来说有着不小的帮助,虽然VisualStudio本身支持C#语法高亮,但也只是对关键字.类名.字符串等少数元素加了标记,而我们代码中主题:变量.函数.属性.事件等都没有进行高亮 ...
- listview侧滑菜单swipemenulistview的简单使用
先看代码: public class MainActivity extends AppCompatActivity { private SwipeMenuListView list; private ...
- php下载网络图片到服务器
/** * 下载二维码到服务器 * @param string $url 图片路径 * @param string $filestring 要保存的文件名 */ private function ...
- MySQL中存储过程+事件的使用方法
一.背景 将界面操作日志存储在MySQL数据库中的operationlog表中,如果该表不能自动备份,表中的数据会越来越多,影响速度.可以定期将表中数据备份到另外一个表中来解决. 二.解决方案 1.使 ...
- Angular JS中$timeout的用法及其与window.setTimeout的区别
$timeout的用法 angular.js的$timeout指令对window.setTimeout做了一个封装,它的返回值是一个promise对象.当定义的时间到了以后,这个promise对象就会 ...