HDU 1069 monkey an banana DP LIS
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"iostream"
#include"cstring"
#include"algorithm"
typedef long long ll;
using namespace std; const int maxn=+; int cass=; struct node
{
int x,y,z;
void get(int x2,int y2,int z2)
{
x=x2;
y=y2;
z=z2;
}
}a[maxn]; bool cmp(node a1,node a2)
{
int su1=a1.x*a1.y;
int su2=a2.x*a2.y;
return su1>su2;
} int n;
int k;
ll h[maxn]; bool is(node a1,node a2)
{
if(a1.x<a2.x&&a1.y<a2.y) return true;
return false;
} void Init()
{
int x1,y1,z1;
k=;
a[].x=a[].y=;
for(int i=;i<n;i++)
{
cin>>x1>>y1>>z1;
a[k++].get(x1,y1,z1);
a[k++].get(y1,x1,z1);
a[k++].get(z1,y1,x1);
a[k++].get(x1,z1,y1);
a[k++].get(y1,z1,x1);
a[k++].get(z1,x1,y1);
}
sort(a+,a+k+,cmp);
} void Work()
{
ll MAX=;
int i,j;
memset(h,,sizeof(h));
for(i=;i<k;i++)
{
for(j=;j<i;j++)
{
if(is(a[i],a[j])&&a[i].z+h[j]>h[i])
h[i]=a[i].z+h[j];
}
MAX=max(h[i],MAX);
}
cout<<"Case "<<++cass<<": maximum height = "<<MAX<<endl;
} int main()
{
while(cin>>n&&n)
{
Init();
Work();
}
return ;
}
HDU 1069 monkey an banana DP LIS的更多相关文章
- HDU 1069 Monkey and Banana DP LIS变形题
http://acm.hdu.edu.cn/showproblem.php?pid=1069 意思就是给定n种箱子,每种箱子都有无限个,每种箱子都是有三个参数(x, y, z)来确定. 你可以选任意两 ...
- HDU 1069 Monkey and Banana DP LIS
http://acm.hdu.edu.cn/showproblem.php?pid=1069 题目大意 一群研究员在研究猴子的智商(T T禽兽啊,欺负猴子!!!),他们决定在房顶放一串香蕉,并且给猴子 ...
- HDU 1069 Monkey and Banana dp 题解
HDU 1069 Monkey and Banana 纵有疾风起 题目大意 一堆科学家研究猩猩的智商,给他M种长方体,每种N个.然后,将一个香蕉挂在屋顶,让猩猩通过 叠长方体来够到香蕉. 现在给你M种 ...
- 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 Problem Description A group of researchers are designing an experiment to test the ...
- HDU 1069 Monkey and Banana(LIS最长上升子序列)
B - LIS Time Limit:1000MS Memory Limit:32768KB 64bit IO Format:%I64d & %I64u Descripti ...
- hdu(1069)——Monkey and Banana(LIS变形)
题意: 如今给你n个石块,然后它由坐标来表示(x,y,z).可是它能够有不同的方法,也就是说它的三个坐标能够轮换着来的. 石块的数量不限,可是每次都必须保持上底面的长和宽严格递减,然后问你用这些石块所 ...
- 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 ...
- HDU 1069 Monkey and Banana(转换成LIS,做法很值得学习)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1069 Monkey and Banana Time Limit: 2000/1000 MS (Java ...
随机推荐
- Problem E: Automatic Editing
Problem E: Automatic EditingTime Limit: 1 Sec Memory Limit: 128 MBSubmit: 3 Solved: 3[Submit][Status ...
- JZOI
orz..kpm大神做的JZOI卡.很好看 目前是全球限量十张哈哈哈 (正面) (背面) 原图:
- 实时消息传输协议 RTMP(Real Time Messaging Protocol)
实时消息传输协议(RTMP)最初是由 Macromedia 为互联网上 Flash player 和服务器之间传输音频.视频以及数据流而开发的一个私有协议.Adobe 收购 Macromedia 购以 ...
- InputStream和OutputStream 何时使用
原文引自:http://blog.csdn.net/fyxxq/article/details/7071978 记得刚学习程序流一章的时候,就是搞不清楚In和Out,不知道什么时候用in什么时候用ou ...
- [LeetCode]题解(python):073-Set Matrix Zeroes
题目来源: https://leetcode.com/problems/set-matrix-zeroes/ 题意分析: 输入一个m×n矩阵,如果出现有0,那么将对应的行和列都变成0. 题目思路: 简 ...
- 修改html很实用的insertAdjacentHTML方法
添加HTML内容与文本内容以前用的是innerHTML与innerText方法, 最近发现还有insertAdjacentHTML和 insertAdjacentText方法, 这两个方法更灵活,可以 ...
- elk 分布式数据同步
zjtest7-redis:/elk/elasticsearch/data/es_cluster/nodes/0/indices/library# strings ./1/index/_3.cfs | ...
- 《Java4Android视频教程》学习笔记(一)
此为个人的学习笔记,所以不具备太强的学习性,若有错误请谅解,如果能指出我的错误,我将万分感谢~ 一:java历史 java诞生 前身:Oak->java 曾经的名字C++(++--) 原意是在C ...
- JAVA FILE or I/O学习 - Desktop本地程序学习
public class DesktopKnow { public void know() { try { Desktop.getDesktop().open(new File("C:\\P ...
- c 输出9x9乘法口诀表 这个学for循环绕不开的一题
#include<stdio.h> int main(void) { int i,j; ;i<=;i++) { ;j<=i;j++) { printf("%d*%d= ...