UVA 437 十九 The Tower of Babylon
2015-08-30 20:48
465 查看
The Tower of Babylon
Time Limit:3000MS Memory Limit:0KB 64bit IO Format:%lld & %llu
Submit Status Practice UVA 437
Appoint description:
System Crawler (2015-08-29)
Description
View Code
Time Limit:3000MS Memory Limit:0KB 64bit IO Format:%lld & %llu
Submit Status Practice UVA 437
Appoint description:
System Crawler (2015-08-29)
Description
#include <stdio.h> #include <string.h> #include <algorithm> using namespace std; struct Node { int l; int r; int h; int s; }; Node a[100]; bool cmp(Node p,Node q) { return p.s<q.s; } int main() { int N,n; int i,j,k=1; int dp[100]; while(scanf("%d",&N)!=EOF && N!=0) { n=0; memset(dp,0,sizeof(dp)); for(i=1;i<=N;i++) { int x,y,z; scanf("%d %d %d",&x,&y,&z); n++; a .l=max(x,y),a .r=min(x,y),a .h=z,a .s=x*y; n++; a .l=max(x,z),a .r=min(x,z),a .h=y,a .s=x*z; n++; a .l=max(z,y),a .r=min(z,y),a .h=x,a .s=z*y; } sort(a+1,a+n+1,cmp); dp =a .h; int ans=dp ; for(i=n-1;i>=1;i--) { int max=0; for(j=i+1;j<=n;j++) { if(a[i].l<a[j].l && a[i].r<a[j].r && dp[j]>max) max=dp[j]; } dp[i]=max+a[i].h; if(dp[i]>ans) ans=dp[i]; } printf("Case %d: maximum height = %d\n",k++,ans); } return 0; }
View Code
相关文章推荐
- 数据库面试题
- 卸载win10内置windows app的方法
- chrmoe debug
- IE8下兼容rgba颜色的半透明背景
- UVA 10254 十八 The Priest Mathematician
- 基于cordova的 百度混音插件 iOS版
- wamp 中添加虚拟主机
- iOS_UI_1_UIView
- 冒泡排序
- 字符串排列
- iOS常用设计模式——原型模式
- Android4.0以上版本Http请求的问题
- UVA 10453 十七 Make Palindrome
- html5位置定位
- 深入浅出CChart 每日一课——快乐高四第十三课 月上柳梢,Win32标准控件ChartCtrl之牵手
- 在resin4.0部署项目,出现server 'default' 错误
- IOS面试题归总
- UVA 10163 十六 Storage Keepers
- 八、MDT 2013 Update 1批量部署-修改配置文件BootStrap.ini和CustomSettings.ini
- 站在十字路口的中国电视