#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<map>
using namespace std;
#define inf 0x3f3f3f3f
#define eps 1e-8
#define ll long long
#define ull unsigned long long
#define For( i, x, y ) for( int i = x; i < y; ++i )
#define mxn 10200
struct node {
int x, y, h, s;
bool operator < ( const node b ) const {
return s > b.s; //按面积排序
}
}a[mxn];
int dp[mxn];
int main() {
int n;
int cas = 1;
while( cin >> n && n ) {
node t;
int cnt = 0;
For( i, 0, n ) {
cin >> t.x >> t.y >> t.h;
t.s = t.x * t.y;
a[cnt++] = t;
swap( t.x, t.h );
t.s = t.x * t.y;
a[cnt++] = t;
swap( t.y, t.h );
t.s = t.x * t.y;
a[cnt++] = t;
}
sort( a, a + cnt );
int mx = 0;
memset( dp, 0, sizeof( dp ) );
mx = dp[0] = a[0].h;
For( i, 1, cnt ) {
For( j, 0, i ) {
if( ( a[j].x > a[i].x && a[j].y > a[i].y ) || ( a[j].y > a[i].x && a[j].x > a[i].y ) ) {
dp[i] = max( dp[i], dp[j] + a[i].h );
}
}
dp[i] = max( dp[i], a[i].h );
mx = max( dp[i], mx );
}
cout << "Case " << cas++ << ": maximum height = " << mx << endl;
}
return 0;
}
HDU 1069 Monkey and Banana

最新推荐文章于 2020-09-10 19:18:10 发布
