青青草原综合久久大伊人导航_色综合久久天天综合_日日噜噜夜夜狠狠久久丁香五月_热久久这里只有精品

coreBugZJ

此 blog 已棄。

To Miss Our Children Time, The 36th ACM/ICPC Asia Regional Dalian Site —— Online Contest

To Miss Our Children Time

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65768/65768 K (Java/Others)

Problem Description
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?
 

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.
 

Output
Output a line contains a integer describing the highest "Skyscraper"'s height using the n blocks.
 

Sample Input
3
10 10 12 0
10 10 12 1
10 10 11 2
2
10 10 11 1
10 10 11 1
0
 

Sample Output
24
11
 


先排序,然后動態規劃,dp[ i ] 表示以第 i 個長方體放在頂上的最大高度。
注意長寬相乘使用32位整數會溢出。


 1 #include <iostream>
 2 #include <algorithm>
 3 
 4 using namespace std;
 5 
 6 typedef  int  I32;
 7 typedef  long long  I64;
 8 
 9 struct Block
10 {
11          I64 a, b, c, d;
12 };
13 
14 bool operator<const Block &a, const Block &b ) {
15         return (  (a.a  < b.a) || 
16                  ((a.a == b.a)&&(a.b  < b.b)) || 
17                  ((a.a == b.a)&&(a.b == b.b)&&(a.d > b.d))
18                );
19 }
20 
21 const I32 N = 1009;
22 
23 I64    dp[ N ];
24 Block  bk[ N ];
25 
26 int main() {
27         I32 n, i, j;
28         I64 ans, t;
29         for ( ; ; ) {
30                 cin >> n;
31                 if ( n < 1 ) {
32                         break;
33                 }
34                 for ( i = 1; i <= n; ++i ) {
35                         cin >> bk[ i ].a >> bk[ i ].b >> bk[ i ].c >> bk[ i ].d;
36                         if ( bk[ i ].a < bk[ i ].b ) {
37                                 t = bk[ i ].a;
38                                 bk[ i ].a = bk[ i ].b;
39                                 bk[ i ].b = t;
40                         }
41                 }
42                 sort( bk+1, bk+n+1 );
43 
44                 for ( i = 1; i <= n; ++i ) {
45                         dp[ i ] = bk[ i ].c;
46                 }
47                 for ( i = 2; i <= n; ++i ) {
48                         switch ( bk[ i ].d ) {
49                         case 0 : 
50                                 for ( j = 1; j < i; ++j ) {
51                                         if ( (bk[j].a<=bk[i].a) && 
52                                              (bk[j].b<=bk[i].b) && 
53                                              (dp[j]+bk[i].c>dp[i]) 
54                                            ) {
55                                                 dp[ i ] = dp[ j ] + bk[ i ].c;
56                                         }
57                                 }
58                                 break;
59                         case 1 : 
60                                 for ( j = 1; j < i; ++j ) {
61                                         if ( (bk[j].a<=bk[i].a) && 
62                                              (bk[j].b<=bk[i].b) && 
63                                              (bk[j].a*bk[j].b < bk[i].a*bk[i].b) && 
64                                              (dp[j]+bk[i].c>dp[i]) 
65                                            ) {
66                                                 dp[ i ] = dp[ j ] + bk[ i ].c;
67                                         }
68                                 }
69                                 break;
70                         case 2 : 
71                                 for ( j = 1; j < i; ++j ) {
72                                         if ( (bk[j].a<bk[i].a) && 
73                                              (bk[j].b<bk[i].b) && 
74                                              (dp[j]+bk[i].c>dp[i]) 
75                                            ) {
76                                                 dp[ i ] = dp[ j ] + bk[ i ].c;
77                                         }
78                                 }
79                                 break;
80                         }
81                 }
82 
83                 ans = dp[ 1 ];
84                 for ( i = 2; i <= n; ++i ) {
85                         if ( ans < dp[ i ] ) {
86                                 ans = dp[ i ];
87                         }
88                 }
89 
90                 cout << ans << endl;
91         }
92         return 0;
93 }
94 

posted on 2011-09-03 18:24 coreBugZJ 閱讀(1220) 評論(0)  編輯 收藏 引用 所屬分類: ACM

青青草原综合久久大伊人导航_色综合久久天天综合_日日噜噜夜夜狠狠久久丁香五月_热久久这里只有精品
  • <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>
            国内精品亚洲| 亚洲国产精品高清久久久| 国产精品xxxxx| 国产精品jvid在线观看蜜臀 | 国产日韩久久| 国产美女精品一区二区三区| 国产伦精品一区二区三区在线观看| 亚洲专区免费| 亚洲一区在线观看视频 | 欧美一区二区视频网站| 欧美一级免费视频| 久久精品一区二区国产| 久久亚洲一区二区| 欧美国产高清| 一本色道**综合亚洲精品蜜桃冫 | 99热这里只有成人精品国产| 亚洲靠逼com| 在线视频精品| 午夜精彩国产免费不卡不顿大片| 亚洲精品久久在线| 宅男在线国产精品| 欧美影院成人| 美女精品一区| 亚洲精品视频免费观看| 亚洲图片欧洲图片日韩av| 亚洲欧美在线磁力| 老司机一区二区| 欧美日韩在线不卡| 国语自产偷拍精品视频偷| 亚洲欧洲日产国产网站| 亚洲一区二区免费视频| 久久精品毛片| 亚洲人成在线观看网站高清| 亚洲视频大全| 久久综合狠狠| 国产精品视频免费一区| 亚洲高清视频一区| 亚洲中午字幕| 欧美插天视频在线播放| 一本久久知道综合久久| 久久久久久精| 欧美午夜在线| 亚洲国产高清高潮精品美女| 亚洲小说区图片区| 麻豆成人av| 一区二区三区免费在线观看| 久久久国产精品亚洲一区| 欧美日韩国产探花| 一区二区在线视频播放| 亚洲影视在线播放| 欧美α欧美αv大片| 亚洲午夜精品一区二区三区他趣| 在线亚洲激情| 你懂的国产精品永久在线| 国产精品视频久久| 亚洲麻豆国产自偷在线| 久久久免费观看视频| 日韩亚洲欧美在线观看| 久久一区中文字幕| 国产精品电影在线观看| 亚洲国产毛片完整版| 欧美一区二区三区电影在线观看| 亚洲欧美日本国产有色| 欧美激情亚洲另类| 欧美中文字幕视频| 欧美日韩视频在线| 亚洲激情电影在线| 久久看片网站| 亚洲一区www| 欧美日韩蜜桃| 亚洲免费观看在线观看| 老牛影视一区二区三区| 亚洲欧美日韩爽爽影院| 欧美日韩中文字幕| 亚洲麻豆一区| 亚洲成人在线免费| 先锋影音国产精品| 亚洲精品欧美在线| 欧美ab在线视频| 在线电影一区| 久久婷婷久久| 欧美一区二区视频在线| 国产精品午夜电影| 亚洲在线视频| 99精品国产福利在线观看免费| 亚洲在线黄色| 欧美网站在线观看| 一区二区欧美日韩视频| 亚洲激情综合| 美女成人午夜| 亚洲电影成人| 欧美成人xxx| 美女精品视频一区| 亚洲电影第三页| 欧美成人自拍视频| 蜜桃av一区二区三区| 亚洲福利视频网站| 男人插女人欧美| 免费国产一区二区| 亚洲精品偷拍| 亚洲精品一二三区| 欧美午夜激情在线| 亚洲欧美日韩久久精品| 亚洲一级网站| 国产日韩欧美制服另类| 久久久999精品免费| 久久精品国产成人| 亚洲电影第三页| 亚洲激情另类| 欧美天堂亚洲电影院在线观看| 在线观看成人网| 欧美成人一区二区三区片免费| 亚洲图片激情小说| 国产乱肥老妇国产一区二| 久久理论片午夜琪琪电影网| 久久久久成人精品免费播放动漫| 欧美日韩一区在线观看| 亚洲综合色丁香婷婷六月图片| 欧美高清视频一区二区| 麻豆成人小视频| 夜夜嗨av一区二区三区| 一区二区日本视频| 国产精品一区二区三区免费观看| 一本色道**综合亚洲精品蜜桃冫 | 免费不卡在线视频| 免费欧美在线视频| 日韩网站在线观看| 亚洲永久免费精品| 激情校园亚洲| 日韩视频精品在线观看| 国产日韩av在线播放| 免费人成精品欧美精品| 欧美日韩国产精品专区| 亚洲欧美一区二区激情| 久久久久网站| 亚洲四色影视在线观看| 欧美一区亚洲| 亚洲免费av网站| 香蕉乱码成人久久天堂爱免费| 国产精品色一区二区三区| 毛片av中文字幕一区二区| 欧美理论电影网| 欧美影院精品一区| 蜜臀av性久久久久蜜臀aⅴ| 亚洲一区二区av电影| 欧美在线观看你懂的| 99视频精品全国免费| 香蕉久久夜色精品国产| 亚洲精品乱码视频| 午夜精品视频| 一区二区三区高清在线| 欧美在线黄色| 亚洲一区二区精品在线| 久久久久久亚洲精品不卡4k岛国| 国外成人性视频| 99精品视频免费| 在线观看视频一区二区| 亚洲性夜色噜噜噜7777| 亚洲狠狠丁香婷婷综合久久久| 欧美福利电影在线观看| 国产精品视频专区| 亚洲欧洲一区二区三区在线观看| 欧美电影打屁股sp| 久久久久久久尹人综合网亚洲| 性色av一区二区三区| 一区电影在线观看| 久久久久99| 性色一区二区三区| 欧美日韩国产一区二区三区| 久久这里只精品最新地址| 国产精品国产三级国产普通话三级 | 一区二区三区偷拍| 亚洲激情国产精品| 欧美在线视频导航| 亚洲欧美日韩国产精品| 欧美gay视频激情| 久久婷婷久久| 国产午夜精品在线观看| 亚洲视频在线播放| 99视频精品在线| 欧美成人日韩| 亚洲第一精品久久忘忧草社区| 欧美日韩不卡| 欧美韩国一区| 亚洲成人在线视频播放| 欧美一区二区成人| 欧美在线影院在线视频| 国产精品理论片在线观看| 一本色道久久| 亚洲色诱最新| 欧美日韩一区二区精品| 亚洲精品资源| 一本色道久久综合亚洲精品婷婷 | 欧美一区二区三区在线观看| 亚洲视频一区在线| 欧美日韩精品系列| 亚洲精品在线电影| a91a精品视频在线观看| 欧美精品自拍| 亚洲精品欧美在线|