poj2241 = hdu1069
来源:互联网 发布:黑客帝国数字雨 算法 编辑:程序博客网 时间:2024/05/21 10:14
<span style="font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; font-size: 13px; line-height: 19px; background-color: rgb(40, 85, 126);">题:http://poj.org/problem?id=2241</span>
<span style="font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; font-size: 13px; line-height: 19px; background-color: rgb(40, 85, 126);">意:已知有n(n<30)种类型的block,以及它们的长宽高,每种类型的block都有无限多个。问如果把他们叠起来(上面block的底面的长宽,必须比下面的block的底面长宽都短),最高能有多高。</span>
#include<iostream>//poj2241 DAG上的DP#include<cstdio>#include<list>#include<cstring>#include<string>#include<queue>#include<stack>#include<map>#include<vector>#include<cmath>#include<memory.h>#include<set>using namespace std;int dp[100000 + 5]; struct Node { int l,w,h; void newday(int x,int y,int z){ l = x,w = y, h = z; }}node[100000 + 5];bool cmp(Node x,Node y) { return x.l * x.w < y.l * y.w;}int main() { int n,i,j,k; int Case = 0;//cout<<EXIT_SUCCESS<<endl; while(scanf("%d",&n),n) {memset(dp,0,sizeof(dp));memset(node,0,sizeof(node)); int tot = 0; for( i=1;i<=n;i++) { int x,y,z; scanf("%d %d %d",&x,&y,&z); node[++tot].newday(x,y,z); node[++tot].newday(x,z,y); node[++tot].newday(y,x,z); node[++tot].newday(y,z,x); node[++tot].newday(z,x,y); node[++tot].newday(z,y,x); } sort(node + 1,node + tot,cmp); for(i=1;i<=tot;i++) dp[i] = node[i].h; int ans = 0; for( i=2;i<=tot;i++) { for( j=1;j<i;j++) //类似拦截导弹{ if(node[i].l> node[j].l && node[i].w > node[j].w) dp[i] = _cpp_max(dp[i],dp[j] + node[i].h); } if( ans < dp[i])ans = dp[i]; } printf("Case %d: maximum height = %d\n",++Case,ans);//cout<<EXIT_SUCCESS<<endl; } return EXIT_SUCCESS;//EXIT_FAILURE#define EXIT_SUCCESS 200}
0 0
- poj2241 = hdu1069
- hdu1069
- hdu1069
- hdu1069
- hdu1069
- HDU1069
- hdu1069
- HDU1069
- hdu1069
- hdu1069
- HDU1069
- HDU1069
- [POJ2241]最高巴比伦塔
- hdu1069(dp)
- HDU1069(DAG)
- poj2241 - The Tower of Babylon
- POJ2241:The Tower of Babylon
- POJ2241——The Tower of Babylon
- UI Automation-TransformPattern
- 利用ComboBox和SymbologyControl控件实现下拉式颜色带
- 记录ubuntu12.04的使用
- 产生pod的方法
- 远程控制是管理人员在异地通过计算机网络
- poj2241 = hdu1069
- 基于lucene的案例开发:lucene初始认知
- The archive contains
- 通过Spring @PostConstruct 和 @PreDestroy 方法 实现初始化和销毁bean之前进行的操作
- UI Automation-MultipleViewPattern
- iOS 判断并使用 百度地图 高德地图 导航(使用URI,不集成sdk)
- 原码&反码&补码
- java实现纯真ip搜索
- UI Automation-GridPattern