杭电4001 亚洲区预赛大连赛区
来源:互联网 发布:iphone蜂窝数据3g 编辑:程序博客网 时间:2024/04/30 16:23
这道题做了有两天了吧,今天才总算找到错误,本来我想了一种思路,一直wr,找错误一直找不到,今天下午吃过饭后和lky讨论了一下,才总算明白我的思路错在了哪里,看来,互相交流还是很有必要的啊。。。。。。。。。题目:
Do you remember our children time? When we are children, we are interesting in almost everything around ourselves. A little thing or a simple game will brings us lots of happy time! LLL is a nostalgic boy, now he grows up. In the dead of night, he often misses something, including a simple game which brings him much happy when he was child. Here are the game rules: There lies many blocks on the ground, little LLL wants build "Skyscraper" using these blocks. There are three kinds of blocks signed by an integer d. We describe each block's shape is Cuboid using four integers ai, bi, ci, di. ai, bi are two edges of the block one of them is length the other is width. ci is
thickness of the block. We know that the ci must be vertical with earth ground. di describe the kind of the block. When di = 0 the block's length and width must be more or equal to the block's length and width which lies under the block. When di = 1 the block's length and width must be more or equal to the block's length which lies under the block and width and the block's area must be more than the block's area which lies under the block. When di = 2 the block length and width must be more than the block's length and width which lies under the block. Here are some blocks. Can you know what's the highest "Skyscraper" can be build using these blocks?
thickness of the block. We know that the ci must be vertical with earth ground. di describe the kind of the block. When di = 0 the block's length and width must be more or equal to the block's length and width which lies under the block. When di = 1 the block's length and width must be more or equal to the block's length which lies under the block and width and the block's area must be more than the block's area which lies under the block. When di = 2 the block length and width must be more than the block's length and width which lies under the block. Here are some blocks. Can you know what's the highest "Skyscraper" can be build using these blocks?
Input
The input has many test cases.
For each test case the first line is a integer n ( 0< n <= 1000) , the number of blocks.
From the second to the n+1'th lines , each line describing the i‐1'th block's a,b,c,d (1 =< ai,bi,ci <= 10^8 , d = 0 or 1 or 2).
The input end with n = 0.
For each test case the first line is a integer n ( 0< n <= 1000) , the number of blocks.
From the second to the n+1'th lines , each line describing the i‐1'th block's a,b,c,d (1 =< ai,bi,ci <= 10^8 , d = 0 or 1 or 2).
The input end with n = 0.
Output
Output a line contains a integer describing the highest "Skyscraper"'s height using the n blocks.
Sample Input
310 10 12 010 10 12 110 10 11 2210 10 11 110 10 11 10
Sample Output
2411
#include <iostream>#include <algorithm>#include <cstdio>using namespace std;struct block{ _int64 len; _int64 wid; _int64 hi; _int64 num;}aa[1005];bool cmp(block a,block b){ if(a.len==b.len) { if(a.wid==b.wid)return a.num>b.num;return a.wid<b.wid; } return a.len<b.len;}int main(){ int n; while(scanf("%d",&n)) { if(n==0)return 0;int i,j;_int64 a,b,dp[1005];for(i=0;i<n;++i){ scanf("%I64d%I64d%I64d%I64d",&a,&b,&aa[i].hi,&aa[i].num); if(a>b) {aa[i].len=a;aa[i].wid=b;} else {aa[i].len=b;aa[i].wid=a;} }sort(aa,aa+n,cmp);for(i=0;i<n;++i)dp[i]=aa[i].hi;_int64 mmax=dp[0];for(i=1;i<n;++i){ for(j=0;j<i;++j) { if(aa[i].num==0){ if(aa[i].len>=aa[j].len&&aa[i].wid>=aa[j].wid&&dp[i]<aa[i].hi+dp[j]) dp[i]=dp[j]+aa[i].hi;}else if(aa[i].num==1){ if(aa[i].len>=aa[j].len&&aa[i].wid>=aa[j].wid&&(aa[i].len>aa[j].len||aa[i].wid>aa[j].wid)&&dp[i]<aa[i].hi+dp[j]) dp[i]=dp[j]+aa[i].hi;}else{ if(aa[i].len>aa[j].len&&aa[i].wid>aa[j].wid&&dp[i]<aa[i].hi+dp[j]) dp[i]=dp[j]+aa[i].hi;} } if(dp[i]>mmax) mmax=dp[i];}printf("%I64d\n",mmax); } return 0;}
- 杭电4001 亚洲区预赛大连赛区
- 杭电 4006 亚洲区预赛大连赛区
- 杭电4002 亚洲区预赛大连赛区
- 杭电4004 亚洲区预赛大连赛区
- 杭电 4007 亚洲区域赛大连赛区
- 动态规划 杭电4001 大连赛区网络赛水题
- 杭电 4004 大连赛区网络赛。
- 大连,第36届ACM国际大学生程序设计竞赛,亚洲区大连赛区预选赛
- 杭电4011 亚洲区域赛上海赛区网络热身赛
- ACM亚洲预赛福州赛区入围晋级赛 总结
- ACM-ICPC国际大学生程序设计竞赛亚洲区大连赛区(2016)地区赛——花开花落终有时
- HDU 4004 - The Frog\'s Games 第36届ACM/ICPC亚洲大连赛区网络赛
- 2017 icpc亚洲区预赛西安站 J LOL
- HDU5876 Sparse Graph(2016亚洲区大连站网络赛)
- HDU5971, 2016ACM/ICPC亚洲区大连站第一题
- 2016ACM/ICPC亚洲区大连站【solved:10 / 11】
- 2016ACM/ICPC亚洲区大连站 H
- 2016ACM/ICPC亚洲区大连站 I
- 第十三章 2 多线程的优先级和同步
- 手机全平台开发
- java线程(No.7)
- Thawte Java(J2ME)代码签名证书操作指南
- SQL语句大全(一)
- 杭电4001 亚洲区预赛大连赛区
- Thread1
- 线程的生命周期、线程的同步
- 在Hibernate中配置一对多连接表
- 用python+wxpython写的音乐播放器
- Mysql复习
- Lua的function、closure和upvalue
- grub 进入单人维护模式
- PHP Deprecated: Call-time pass-by-reference has been deprecated in /var/www/html/bugfree/Include/Cl