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 ...
随机推荐
- Contributing to Open Source on GitHub(转)
A great way to get involved in open source is to contribute to the existing projects you’re using. G ...
- USACO Section 5.3 Milk Measuring (IDDFS+dp)
迭代加深搜索,从小到大枚举桶数的上限maxd:对每个maxd,枚举每个组合,判断是否能够倒出q:直到得到answer.判断的部分就用dp(完全背包). ------------------------ ...
- Spring学习之Aop的各种增强方法
AspectJ允许使用注解用于定义切面.切入点和增强处理,而Spring框架则可以识别并根据这些注解来生成AOP代理.Spring只是使用了和AspectJ 5一样的注解,但并没有使用AspectJ的 ...
- mysql修改用户名和密码
修改用户名 mysql> use mysql; 选择数据库Database changedmysql> update user set user="dns" wher ...
- javascript函数querySelector
querySelector用于获得dom节点,可以接受三种类型的参数:id(#),class(.),标签.很像jquery的选择器.不过只能返回一个子孙元素,但是jquery选择器的话,可以返回一组元 ...
- PHP CI框架最近学到的内容
CI框架配置方面注意的细节 在config里面的database.php里面是和数据库配置相关的内容 $db['default'] = array( 'dsn' => '', 'hostname ...
- Qt 智能指针学习(7种QT的特有指针)
从内存泄露开始? 很简单的入门程序,应该比较熟悉吧 ^_^ #include <QApplication> #include <QLabel> int main(int arg ...
- Python+django开发环境搭建
Python目前主版本有2个,2.7+和3.4+ 新入手,决定还是从2.7开始 先从python官网https://www.python.org/下载python2.7.10,64位版本(这里注意,选 ...
- Flex疑难小杂症
本文主要解决Flex中一些小问题,收集一些小技巧(来自网络及个人经验) flex自动换行问题 有时候由于label .button等控件中需要用到text属性显示出文本,文本太长就涉及到换行问题,解 ...
- [Python]Unicode转ascii码的一个好方法
写这篇文章的是一位外国人,他遇到了什么问题呢?比如有一个 Unicode 字符串他需要转为 ascii码: >>> title = u"Klüft skräms inför ...