hdu1069 Monkey and Banana LIS
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<queue>
#include<map>
#include<vector>
#include<set>
#include<string>
#include<cmath>
#include<cstring>
using namespace std;
typedef struct{
int x;
int y;
int z;
}t;
t tt[];
bool cmp(t t1,t t2)
{
if(t1.x!=t2.x)
return t1.x<t2.x;
else if(t1.y!=t2.y)
return t1.y<t2.y;
else return t1.z<t2.z;
}
int n;
int dp[];
int main()
{
int c=;
while(~scanf("%d",&n)&&n!=)
{
int cnt=;
for(int i=;i<n;i++)
{
int a,b,c;
scanf("%d%d%d",&a,&b,&c);
{//一组数据有6种情况
tt[cnt].x=a;
tt[cnt].y=b;
tt[cnt++].z=c; tt[cnt].x=a;
tt[cnt].y=c;
tt[cnt++].z=b; tt[cnt].x=b;
tt[cnt].y=a;
tt[cnt++].z=c; tt[cnt].x=b;
tt[cnt].y=c;
tt[cnt++].z=a; tt[cnt].x=c;
tt[cnt].y=a;
tt[cnt++].z=b; tt[cnt].x=c;
tt[cnt].y=b;
tt[cnt++].z=a;
}
}
sort(tt,tt+cnt,cmp); dp[]=tt[].z;
int res=;
for(int i=;i<cnt;i++)
{
int maxx=; for(int j=;j<i;j++)
{
if(tt[i].x>tt[j].x&&tt[i].y>tt[j].y)
{
// printf(" i=%d j=%d\n",i,j); maxx=max(maxx,dp[j]);
} }
dp[i]=tt[i].z+maxx;
res=max(res,dp[i]);
} printf("Case %d: maximum height = %d\n",c++,res);
}
return ;
}
hdu1069 Monkey and Banana LIS的更多相关文章
- HDU1069 Monkey and Banana
HDU1069 Monkey and Banana 题目大意 给定 n 种盒子, 每种盒子无限多个, 需要叠起来, 在上面的盒子的长和宽必须严格小于下面盒子的长和宽, 求最高的高度. 思路 对于每个方 ...
- HDU1069 Monkey and Banana —— DP
题目链接:http://acm.split.hdu.edu.cn/showproblem.php?pid=1069 Monkey and Banana Time Limit: 2000/1000 MS ...
- kuangbin专题十二 HDU1069 Monkey and Banana (dp)
Monkey and Banana Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others ...
- HDU1069:Monkey and Banana(DP+贪心)
Problem Description A group of researchers are designing an experiment to test the IQ of a monkey. T ...
- HDU-1069 Monkey and Banana DAG上的动态规划
题目链接:https://cn.vjudge.net/problem/HDU-1069 题意 给出n种箱子的长宽高 现要搭出最高的箱子塔,使每个箱子的长宽严格小于底下的箱子的长宽,每种箱子数量不限 问 ...
- HDU1069 Monkey and Banana(dp)
链接:http://acm.hdu.edu.cn/showproblem.php?pid=1069 题意:给定n种类型的长方体,每个类型长方体无数个,要求长方体叠放在一起,且上面的长方体接触面积要小于 ...
- HDU1069 - Monkey and Banana【dp】
题目大意 给定箱子种类数量n,及对应长宽高,每个箱子数量无限,求其能叠起来的最大高度是多少(上面箱子的长宽严格小于下面箱子) 思路 首先由于每种箱子有无穷个,而不仅可以横着放,还可以竖着放,歪着放.. ...
- HDU 1069 Monkey and Banana(二维偏序LIS的应用)
---恢复内容开始--- Monkey and Banana Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K ...
- ZOJ 1093 Monkey and Banana (LIS)解题报告
ZOJ 1093 Monkey and Banana (LIS)解题报告 题目链接:http://acm.hust.edu.cn/vjudge/contest/view.action?cid= ...
随机推荐
- markdown使用介绍
一.标题,前面加#,加一个 一级标题,两个二级标题,以此类推. 一级标题 二级标题 三级标题
- Idea的类中使用实体类(有@Data注解)的Get/Set方法报错
今天从svn上面下了一个maven项目,导入到Idea中之后,发现有的类会使用实体类的Set/Get方法(全报错),导致该问题的原因就是因为实体类中没有这个方法,代码类似如下: @Data publi ...
- 运行xv6
我们使用Qemu在Ubuntu下运行 1. 安装Qemu sudo apt-get install qemu 执行 qemu-system-i386 ,如果弹出Qemu界面说明安装成功了 2. 编译x ...
- js数组取对象
数组取对象 var arr1 = [ { id: "1", name: "one", age: "one" }, { id: "2 ...
- 文献阅读报告 - Situation-Aware Pedestrian Trajectory Prediction with Spatio-Temporal Attention Model
目录 概览 描述:模型基于LSTM神经网络提出新型的Spatio-Temporal Graph(时空图),旨在实现在拥挤的环境下,通过将行人-行人,行人-静态物品两类交互纳入考虑,对行人的轨迹做出预测 ...
- HTML5 Canvas——折线图
<script type="text/javascript"> /*1.绘制网格 网格大小 10px 网格的颜色 #ddd */ /*2.绘制坐标 轴的离边距离 20p ...
- css 元素选择器
子元素选择器 h1 > strong {color:red;} //这个规则会把第一个 h1 下面的两个 strong 元素变为红色,但是第二个 h1 中的 strong 不受影响: <h ...
- Django2.0——Form组件简单总结
Django提供了一个Form组件来配和前端的表单进行使用,Form有两个强大的功能,分别是生成HTML代码和验证数据的合法性.通常我们不会用其第一个功能,因为前端的设计可以做出更加精美且多样的表单页 ...
- 吴裕雄--天生自然TensorFlow高层封装:Estimator-自定义模型
# 1. 自定义模型并训练. import numpy as np import tensorflow as tf from tensorflow.examples.tutorials.mnist i ...
- VMware下的Ubuntu16设置连接主机网络,设置主机下可以通过xshell访问 VMware下的Ubuntu
NAT模式连接 1. 2. 3. 4. 5. 6.