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

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>
            国产一区视频观看| 亚洲电影av在线| 欧美高清一区| 久久国产精品亚洲va麻豆| 欧美激情一区二区三区| 免费不卡在线视频| 国产精品素人视频| 99re66热这里只有精品4| 在线成人欧美| 欧美在线国产| 欧美在线看片a免费观看| 欧美日韩国产bt| 欧美激情在线免费观看| 激情久久综合| 久久精品国产综合精品| 午夜一级在线看亚洲| 欧美日韩亚洲一区二区三区四区| 欧美成人午夜免费视在线看片| 国产精品一区二区久久久| 亚洲六月丁香色婷婷综合久久| 亚洲国产精品视频一区| 久久精品夜色噜噜亚洲a∨| 欧美伊人精品成人久久综合97| 国产精品av免费在线观看| 亚洲人成网站在线播| 日韩视频在线观看国产| 毛片一区二区三区| 欧美福利一区| 亚洲精品国产欧美| 欧美国产综合视频| 亚洲另类自拍| 亚洲在线中文字幕| 国产精品青草综合久久久久99| 一区二区三区日韩欧美| 亚洲免费一区二区| 国产欧美一区二区三区国产幕精品| 亚洲一区二区三区免费观看| 午夜精品久久久久久99热| 欧美午夜视频在线观看| 亚洲特级片在线| 欧美一区不卡| 黄色一区二区三区| 免费观看国产成人| 亚洲狼人精品一区二区三区| 亚洲视频自拍偷拍| 国产农村妇女精品| 久久嫩草精品久久久精品一| 欧美激情一区在线| 亚洲视屏在线播放| 国产一区免费视频| 另类激情亚洲| 日韩午夜av电影| 久久精品国产清高在天天线| 精品福利免费观看| 欧美理论片在线观看| 亚洲一区三区视频在线观看| 久久久久久久国产| 亚洲精品少妇| 国产日产欧产精品推荐色| 久热成人在线视频| 亚洲少妇在线| 欧美成人激情在线| 亚洲欧美日韩一区二区在线| 黄色日韩在线| 欧美午夜激情在线| 久久这里只有| 亚洲在线免费| 亚洲精品国产精品国自产观看| 午夜精品久久久久久99热| 亚洲大片在线观看| 国产精品日韩精品欧美精品| 久热国产精品| 午夜精品久久久久久99热软件| 欧美 日韩 国产 一区| 亚洲永久在线| 亚洲精选一区| 国内精品免费午夜毛片| 欧美日韩在线观看一区二区三区 | 欧美深夜影院| 久久午夜精品一区二区| 亚洲婷婷在线| 亚洲人被黑人高潮完整版| 久久综合精品一区| 午夜精品亚洲一区二区三区嫩草| 亚洲电影天堂av| 国产网站欧美日韩免费精品在线观看| 欧美久久99| 久久综合福利| 久久精品亚洲乱码伦伦中文| 一本大道久久a久久精二百| 欧美77777| 久久一区二区三区av| 欧美一激情一区二区三区| 一区二区三区日韩欧美精品| 亚洲国产成人在线| 国内揄拍国内精品少妇国语| 国产精品久久97| 欧美精品在线视频| 欧美高清视频| 欧美国产日产韩国视频| 久久中文字幕导航| 久久久久一区二区三区| 亚洲男人的天堂在线aⅴ视频| 99国产精品视频免费观看一公开| 欧美激情一二区| 欧美成人69| 欧美黄色影院| 亚洲高清视频在线| 亚洲国产裸拍裸体视频在线观看乱了中文| 久久久精品日韩欧美| 久久精品国产精品亚洲综合| 欧美制服丝袜第一页| 性感少妇一区| 久久精品国产综合| 久久中文字幕导航| 老司机午夜精品视频| 久久日韩精品| 欧美91福利在线观看| 欧美 日韩 国产 一区| 欧美成人亚洲| 亚洲国内精品在线| 99xxxx成人网| 亚洲综合不卡| 久久久久久久久综合| 久久天堂成人| 欧美精品一区二区三区蜜桃| 欧美涩涩网站| 国产美女精品在线| 伊人久久噜噜噜躁狠狠躁| 亚洲黄色av| 亚洲天堂免费在线观看视频| 亚洲欧美日韩精品久久久久| 欧美在线free| 欧美成人精品1314www| 亚洲欧洲日产国产综合网| 一本色道久久综合亚洲二区三区| 亚洲午夜免费福利视频| 欧美一区二区在线看| 你懂的视频一区二区| 欧美三级视频| 国产午夜一区二区三区| 亚洲国产色一区| 亚洲宅男天堂在线观看无病毒| 久久9热精品视频| 亚洲第一福利在线观看| 亚洲视频一二| 麻豆成人在线观看| 国产精品久久国产精麻豆99网站| 国产在线精品一区二区中文 | 国产日韩一区欧美| 亚洲国产日韩欧美在线99 | 欧美激情免费观看| 亚洲色图综合久久| 美女视频一区免费观看| 欧美日韩综合网| 在线成人性视频| 亚洲在线播放| 欧美高清不卡| 欧美一区亚洲二区| 欧美三日本三级少妇三2023| 红杏aⅴ成人免费视频| 亚洲午夜一级| 亚洲韩国青草视频| 久久精品一区| 国产精品亚洲人在线观看| 亚洲日本aⅴ片在线观看香蕉| 香蕉av777xxx色综合一区| 欧美激情亚洲自拍| 久久精品亚洲| 国产欧美不卡| 亚洲性av在线| 亚洲七七久久综合桃花剧情介绍| 欧美在线不卡| 国产精品免费看| 亚洲一区二区三区精品视频| 欧美777四色影视在线| 午夜视频在线观看一区二区| 欧美日韩中文字幕在线视频| 在线观看精品| 久久尤物电影视频在线观看| 亚洲女人av| 国产精品久久久久毛片软件| 日韩亚洲精品在线| 欧美大片一区二区| 久久久水蜜桃| 好男人免费精品视频| 久久国产一区二区| 亚洲欧美资源在线| 国产日韩欧美另类| 久久精品国产亚洲5555| 亚洲欧美日韩一区在线| 国产精品久久9| 亚洲综合社区| 亚洲一区二区三区四区视频| 国产精品magnet| 午夜精品电影| 亚洲影院一区| 国产亚洲欧美一区| 久久先锋资源| 男男成人高潮片免费网站|