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 ...
随机推荐
- Linux C网络编程学习笔记
Linux C网络编程总结报告 一.Linux C 网络编程知识介绍: 网络程序和普通的程序有一个最大的区别是网络程序是由两个部分组成的--客户端和服务器端. 客户端:(client) 在网络程序中, ...
- inline-block 垂直居中
<!doctype html> <html lang="en"> <head> <meta charset="UTF-8&quo ...
- LED板上芯片(COB)封装流程
LED 板上芯片(Chip On Board,COB)封装流程是,首先在基底表面用导热环氧树脂(一般用掺银颗粒的环氧树脂)覆盖硅片安放点, 然后将硅片 间接安放正在基底表面,热处理至硅片牢固地固定正在 ...
- FreeBSD 10安装KDE桌面环境简介(亲测bsdconfig命令有效)
FreeBSD 10出来一段时间了,自己摸索装上KDE环境,网上介绍的都是10以前版本的,要么对现在的不合适,走了一大圈弯路还是装不好:要么太繁琐且装了一堆无用的软件.本着让更多人能快速方面的入门Fr ...
- 转:详细解说 STL 排序(Sort)
详细解说 STL 排序(Sort) 详细解说 STL 排序(Sort) 作者Winter 详细解说 STL 排序(Sort) 0 前言: STL,为什么你必须掌握 1 STL提供的Sort 算法 1. ...
- C++模板:字典树
//插入 void insert(char *s,char *s1){ for(int l=strlen(s),x=0,i=0;i<l;i++){ if(!trie[x].son[s[i]-'a ...
- [置顶] 【J2SE 】1136 容器之旅
开篇引言 本篇文章我将要详细的介绍一下什么是容器?以及什么是1136?来系统全面的了解容器,以及容器的应用,下面就进入我们的容器之旅吧! 1.什么是容器? 用来存储和组织其他对象的对象.我们也可以这样 ...
- HDU 4725 The Shortest Path in Nya Graph-【SPFA最短路】
题目:http://acm.hdu.edu.cn/showproblem.php?pid=4725 题意:有N个点和N层..一层有X个点(0<=X<=N).两邻两层间有一条路花费C.还有M ...
- gridview的高级使用
后台数据 using System; using System.Collections.Generic; using System.Linq; using System.Web; using Sy ...
- Oracle表解锁
网搜 --第一步 查看被锁表 select b.owner,b.object_name, b.object_id,l.session_id,l.locked_mode from v$locked_ob ...