码迷,mamicode.com
首页 > 其他好文 > 详细

hdu 1069

时间:2015-04-08 19:52:14      阅读:126      评论:0      收藏:0      [点我收藏+]

标签:

对比一年前的代码 感觉STL用的略浪

 

技术分享
 1 #include <iostream>
 2 #include <algorithm>
 3 #include <queue>
 4 #include <cstring>
 5 #include <cstdio>
 6 #include <vector>
 7 #include <string>
 8 #include <iterator>
 9 #include <cmath>
10 #include <deque>
11 #include <stack>
12 #include <cctype>
13 using namespace std;
14 
15 const int N = 6000;
16 const int INF = 0xfffffff;
17 
18 typedef long long ll;
19 typedef long double ld;
20 
21 #define INFL 0x7fffffffffffffffLL
22 #define met(a, b) memset(a, b, sizeof(a))
23 #define rep(c, a, b) for (int c = a; c < b; c++)
24 #define nre(c, a, b) for (int c = a; c > b; c--)
25 
26 struct box
27 {
28     int x, y, h;
29     bool operator < (const box &a) const
30     {
31         if (x != a.x) return x > a.x;
32         else return y > a.y;
33     }
34 };
35 
36 vector <box> a;
37 vector <int> dp;
38 
39 int main ()
40 {
41     int n, k = 1;
42     while (cin >> n, n)
43     {
44         int x[4];
45         a.clear(); dp.clear();
46         while (n--)
47         {
48             cin >> x[0] >> x[1] >> x[2];
49             sort (x, x + 3);
50             a.push_back ( (box){x[0], x[1], x[2]});
51             a.push_back ( (box){x[0], x[2], x[1]});
52             a.push_back ( (box){x[1], x[2], x[0]});
53         }
54         sort (a.begin(), a.end());
55         rep (i, 0, a.size()){
56             dp.push_back(a[i].h);
57             rep (j, 0, i){
58                 if (a[j].x > a[i].x && a[j].y > a[i].y)
59                     dp[i] = max (dp[i], dp[j] + a[i].h);
60             }
61         }
62         cout << "Case " << k++ << ": maximum height = ";
63         cout << * max_element (dp.begin(), dp.end()) << endl;
64     }
65     return 0;
66 }
View Code

 

hdu 1069

标签:

原文地址:http://www.cnblogs.com/darkdomain/p/4403403.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!