#include<iostream>
#include<algorithm>
#include<map>
#include<set>
#include<vector>
#include<utility>
#include<list>
#include<deque>
#include<queue>
#include<stack>
#include<string>
#include<cstring>
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<cctype>
using namespace std;
typedef long long LL; //数据太大了记得用LL,还有把INF也得换
typedef pair<LL, LL> P;
const int maxn = 1e7+10; //cf数组最多差不多是这么多,1e8就会段错误
const int V_MAX = 800 + 10;
const int mod = 10007;
const int INF = 0x3f3f3f3f; //如果数据范围为long long,记得把INF的值换了
const double eps = 1e-6; //eps开太小二分容易死循环,所以直接来个100次循环就好了
//多组输入时,maxn太大,用memset()会超时,血的教训;
struct rec{
int c, k, h;
rec() {}
rec(int cc, int kk, int hh) : c(cc), k(kk), h(hh) {}
bool operator < (const rec &b) const {
if(c != b.c) return c > b.c;
else return k > b.k;
}
};
int n, kase;
vector<rec> arr;
//dp[i]表示以arr[i]结尾,最高的高度
//dp[i] = max(dp[i], dp[j] + arr[i]);
void solve() {
arr.clear();
for(int i = 0; i < n; i++) {
int a, b, c;
cin >> a >> b >> c;
arr.push_back(rec(a, b, c));
arr.push_back(rec(a, c, b));
arr.push_back(rec(b, a, c));
arr.push_back(rec(b, c, a));
arr.push_back(rec(c, a, b));
arr.push_back(rec(c, b, a));
}
sort(arr.begin(), arr.end());
int cnt = arr.size();
int dp[cnt], ans = 0;
for(int i = 0; i < cnt; i++) {
dp[i] = arr[i].h;
for(int j = 0; j < i; j++) {
if(arr[i].c < arr[j].c && arr[i].k < arr[j].k)
dp[i] = max(dp[i], arr[i].h + dp[j]);
}
ans = max(dp[i], ans);
}
cout << "Case " << ++kase << ": " << "maximum height = " << ans << endl;
}
int main()
{
ios::sync_with_stdio(false); //关了流同步就别用c的输入
//freopen("D:\\in.txt", "r", stdin);
while(cin >> n && n) {
solve();
}
return 0;
}
HDU 1069 Monkey and Banana
最新推荐文章于 2023-04-08 21:38:15 发布