HDU 1069 DP 经典
来源:互联网 发布:mysql查看端口 编辑:程序博客网 时间:2024/06/05 13:36
题目点我
题目大意是给你一些方块的长宽高xyz,你可以无限使用并且可以旋转他们。
问你如何把它们堆得很高,一块堆上另一块的前提是下面那一块的长和宽都大于上面那一块。
很经典
下面是代码
#include <cstdio>#include <cstring>#include <algorithm>#include <cmath>using namespace std;struct po{ int x,y,z;};po a[220];bool cmp(po a,po b){ if(a.x==b.x) return a.y<=b.y; else return a.x<b.x;}int h[220];int main(){ int n; int kase = 1; while(scanf("%d",&n) && n){ int m = 0; for(int i=0,x,y,z;i<n;i++){ scanf("%d%d%d",&x,&y,&z); a[m].x = x , a[m].y = y , a[m].z = z; m++; a[m].x = x , a[m].y = z , a[m].z = y; m++; a[m].x = z , a[m].y = y , a[m].z = x; m++; a[m].x = z , a[m].y = x , a[m].z = y; m++; a[m].x = y , a[m].y = x , a[m].z = z; m++; a[m].x = y , a[m].y = z , a[m].z = x; m++; } sort(a,a+m,cmp); memset(h,0,sizeof(h)); int ans = 0; for(int i=0;i<m;i++) {h[i] = a[i].z;ans = max(ans,h[i]);} for(int i=0;i<m;i++){ for(int j=0;j<=i;j++){ if(a[j].x < a[i].x && a[j].y < a[i].y && h[i]<h[j]+a[i].z){ h[i] = h[j] + a[i].z; ans = max(ans,h[i]); } } } printf("Case %d: maximum height = ",kase++); printf("%d\n",ans); }}
0 0
- HDU 1069 DP 经典
- hdu 1421 经典DP
- hdu 1227(经典dp)
- hdu 1421经典dp
- HDU 1003 经典DP
- hdu 4035 经典期望dp
- hdu 2196(经典树形dp)
- dp经典题目 hdu 2084
- HDU:1069 Monkey and Banana(经典动态规划DP)
- HDU 1069 Monkey and Banana(动态规划DP 经典)
- HDU 2196 Computer 经典树形DP
- HDU——1227(经典DP)
- HDU 2196 Computer(树形dp经典)
- HDU 2196 Computer(经典树形DP)
- hdu 4616 Game ( 经典树形dp )
- hdu 4455 Substrings (经典DP)
- HDU - 1421 搬寝室(经典DP)
- hdu 2196 树形dp经典题目
- C++的一大误区——深入解释直接初始化与复制初始化的区别
- POJ 3172 Scales (01背包 DFS)
- Linux常用命令
- 城市列表-根据拼音首字母排序
- git 命令之git rebase 用法
- HDU 1069 DP 经典
- 剑指offer——二叉树中和为某一值的路径
- CodeForces 685A Robbers' watch
- 数论
- linux中设置别名
- 公用表达式递归求最短路径详解
- 通过正则 来找出特定的字符 可以输出找出的字符 也可输出删除特定字符的原字符串
- poj2386Lake Counting
- win7上搭建scheme环境