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

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 閱讀(1228) 評論(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>
            欧美综合激情网| 美国十次了思思久久精品导航| 亚洲国产精品专区久久| …久久精品99久久香蕉国产| 在线观看亚洲视频| 夜夜嗨av一区二区三区四季av| 一本色道**综合亚洲精品蜜桃冫 | 好吊视频一区二区三区四区| 亚洲大胆人体视频| 欧美mv日韩mv亚洲| 亚洲精品欧美| 久久久久一区二区| 亚洲理论在线观看| 欧美日韩在线一区二区| 国产亚洲午夜| 99亚洲精品| 一区二区三区四区蜜桃| 久久精品一区中文字幕| 欧美手机在线| 欧美一级播放| 亚洲人成网站在线播| 欧美视频在线免费看| 久久精品国产精品亚洲精品| 亚洲肉体裸体xxxx137| 欧美无砖砖区免费| 亚洲人成网站精品片在线观看 | 亚洲国产清纯| 久久疯狂做爰流白浆xx| 久久久亚洲精品一区二区三区| 国产精品看片资源| 日韩亚洲不卡在线| 免费欧美日韩国产三级电影| 亚洲伊人网站| 欧美护士18xxxxhd| 亚洲国产婷婷香蕉久久久久久| 亚洲精品女人| 国产麻豆9l精品三级站| 午夜影视日本亚洲欧洲精品| 久久午夜精品一区二区| 亚洲成人在线视频网站| 亚洲一级二级| 国产精品一区视频网站| 欧美激情精品久久久久久黑人| 久久久久久91香蕉国产| 亚洲欧美视频一区| 亚洲精品中文字幕在线观看| 国产一区二区欧美| 一本一本久久a久久精品综合妖精| 伊人春色精品| 午夜欧美大尺度福利影院在线看| 欧美日韩一二三区| 99在线观看免费视频精品观看| 欧美一区二区三区婷婷月色 | 欧美日韩在线第一页| 欧美成在线视频| 另类天堂视频在线观看| 在线观看亚洲一区| 久久精品99久久香蕉国产色戒 | 欧美精品在线网站| 一区二区日韩伦理片| 一区二区免费在线观看| 亚洲国产片色| 免费在线看成人av| 在线一区二区三区四区| 久久亚洲高清| 欧美大片在线看免费观看| 国语精品中文字幕| 欧美亚洲三区| 久久久噜噜噜久久人人看| 国产欧美一区二区精品忘忧草| 免费观看国产成人| 一区三区视频| 亚洲另类自拍| 一区二区三区你懂的| 欧美国产成人在线| 亚洲日本中文字幕| 亚洲午夜久久久| 亚洲专区在线| 在线激情影院一区| 美女日韩欧美| 亚洲国产精品第一区二区| 亚洲精品女人| 香蕉久久久久久久av网站| 欧美呦呦网站| 欧美日韩免费网站| 一本一本久久a久久精品牛牛影视| 亚洲永久字幕| 免费成人黄色| 亚洲人体一区| 午夜亚洲影视| 一区二区三区在线免费视频| 免费人成精品欧美精品| 91久久久亚洲精品| 激情综合中文娱乐网| 麻豆av一区二区三区| 亚洲精品国产精品乱码不99| 亚洲欧美日韩精品久久亚洲区 | 欧美性做爰毛片| 亚洲欧美成人一区二区在线电影 | 影音先锋一区| 欧美日本国产精品| 羞羞答答国产精品www一本| 欧美aa国产视频| 亚洲午夜日本在线观看| 国模精品娜娜一二三区| 正在播放亚洲| 亚洲视频视频在线| 欧美精品一区二区三区一线天视频 | 亚洲级视频在线观看免费1级| 欧美日韩另类在线| 久久国产主播精品| 99在线精品视频| 亚洲精品少妇| 国产精品一区二区久久久久| 麻豆精品传媒视频| 亚洲一区二区伦理| 亚洲第一在线| 亚洲日本va午夜在线电影| 欧美调教视频| 蜜桃久久av| 欧美在线观看视频| 久久精品视频免费| 日韩亚洲精品电影| 激情综合色综合久久综合| 国产精品sm| 欧美大片91| 亚洲人成在线观看| 久久人人爽爽爽人久久久| 亚洲色在线视频| 最新精品在线| 激情久久五月| 国产视频久久久久| 久久综合色一综合色88| 亚洲欧美视频| 久久阴道视频| 日韩视频第一页| 欧美午夜精品理论片a级按摩| 麻豆精品视频在线| 久久久综合网站| 欧美一区二区私人影院日本 | 亚洲精品字幕| 亚洲第一中文字幕| 欧美成va人片在线观看| 久久午夜电影| 久久婷婷麻豆| 久久五月婷婷丁香社区| 久久深夜福利免费观看| 久久久国产精品一区| 亚洲国产99| 欧美午夜理伦三级在线观看| 欧美人在线观看| 欧美日韩精品一二三区| 亚洲欧美日韩精品久久奇米色影视 | 久久在线免费视频| 美女免费视频一区| 免费亚洲网站| 亚洲欧洲日本mm| 99在线精品观看| 亚洲图片在区色| 性亚洲最疯狂xxxx高清| 久久精品亚洲精品| 久久综合伊人77777| 欧美国产日产韩国视频| 欧美日韩亚洲一区| 国产精品久久网| 国产一区二区三区丝袜 | 欧美激情综合色综合啪啪| 亚洲一区二区三区在线视频| 亚洲一级免费视频| 久久aⅴ国产紧身牛仔裤| 快播亚洲色图| 欧美日韩在线播放| 国产午夜精品一区二区三区视频| 国产欧美一区二区三区另类精品| 韩日精品中文字幕| 亚洲日本成人网| 亚洲欧美成人在线| 久久久亚洲精品一区二区三区 | 亚洲精品资源美女情侣酒店| 亚洲无亚洲人成网站77777 | 一区二区欧美亚洲| 久久成人综合网| 欧美激情综合色| 国产亚洲精品一区二555| 亚洲激情另类| 性欧美激情精品| 亚洲电影av| 欧美一区永久视频免费观看| 欧美成年视频| 国产一区二区黄色| 日韩视频中文字幕| 久久久久国产精品www| 亚洲国产日韩综合一区| 午夜亚洲性色视频| 欧美啪啪成人vr| 在线色欧美三级视频| 午夜国产一区| 亚洲欧洲中文日韩久久av乱码| 欧美一区二区三区在线免费观看| 欧美精品91|