hdu 1069 Monkey and Banana
来源:互联网 发布:动态增加的div 调用js 编辑:程序博客网 时间:2024/06/06 04:52
hdu 1069 Monkey and Banana:
题意:猴子要够到最上方的香蕉通过堆砌起来的箱子,现在又各种的箱子种类为n,给出每种箱子的长宽高,每种的箱子的个数有无限个,因为猴子爬上堆砌起来的箱子要有空的位置可以踩,只能把接触面积小的放在接触面积大的上面,相同的接触面的箱子不能过搭在一起,因此同一种类型的箱子最多只能使用两次,但是要根据箱子的摆放方式,箱子的长宽高(x, y, z),因此箱子有三种的摆放方式(x, y, z)(x, z, y)(y, z, x)
#include <iostream>#include <algorithm>using namespace std;#define MAX 200#define max(a, b) a > b ? a : bstruct Node{int x, y, z;//长宽高};Node b[MAX];int f[MAX];int cmp(Node a, Node b){if (a.x<b.x)return 1;if (a.x==b.x && a.y<b.y)return 1;return 0;}int main(){ int i, j, n, c;int x, y, z;c = 0;while (cin>>n && n){c++;for (i=0,j=0; i<n; i++)//三种摆放方法{cin>>x>>y>>z; b[j].x = x, b[j].y = y, b[j].z = z;b[j+1].x = x, b[j+1].y = z, b[j+1].z = y;b[j+2].x = y, b[j+2].y = z, b[j+2].z = x; j += 3;}for (i=0; i<n*3; i++)//宽小于长if (b[i].x<b[i].y){int t = b[i].x;b[i].x = b[i].y;b[i].y = t;}sort(b, b+n*3, cmp);//按面积大的排序,先比较长,再比较宽int maxtall=0;for (i=0; i<n*3; i++){ f[i] = b[i].z;for (j=0; j<=i; j++)if (b[i].x>b[j].x && b[i].y>b[j].y)f[i] = max(f[i], f[j]+b[i].z);maxtall = max(maxtall, f[i]);} cout<<"Case "<<c<<": maximum height = "<<maxtall<<endl;}return 0;}
0 0
- HDU 1069 Monkey and Banana
- hdu 1069 Monkey and banana
- hdu 1069 Monkey and Banana
- HDU 1069 Monkey and Banana
- hdu 1069 Monkey and Banana
- hdu 1069 Monkey and Banana
- HDU 1069 Monkey and Banana
- hdu 1069 Monkey and Banana
- hdu 1069 Monkey and Banana
- hdu 1069 Monkey and Banana
- HDU 1069 Monkey and Banana
- hdu 1069 Monkey and Banana
- HDU 1069 Monkey and Banana
- hdu 1069 Monkey and Banana
- hdu 1069 Monkey and Banana
- hdu 1069 Monkey and Banana
- HDU 1069 Monkey and Banana
- hdu 1069 Monkey and Banana
- 【动态树】hdu4897
- eclipse debug 学习心得
- Sysbench安装和基准测试
- 使用HBASE用到的几个filter SingleColumnValueFilter,RowFilter,ValueFilter
- Source Insight建工程之Kernel
- hdu 1069 Monkey and Banana
- IOS Crash 分析
- (05春晨)Google搜索技巧
- 事务2.0
- 解决android导入工程乱码问题 可单独转码
- IOS学习之斯坦福大学IOS开发课程笔记(第六课)
- 一个清华学生留学香港后对人生的思考
- cmake+QT+VTK常见错误及解决方法
- 用Python和Pygame写游戏-从入门到精通(16)