标签:
#include <algorithm>
#include <cstring>
#include <cstdio>
using namespace std;
typedef long long LL;
int dp[90*90];
struct mRect{
int x,y,z;
mRect(int a = 0,int b = 0,int c = 0):x(a),y(b),z(c){};
bool operator < (const mRect & a)const{
return x > a.x || (x == a.x && y > a.y) || (x == a.x && y == a.y && z > a.z);
}
bool operator == (const mRect & a)const{
return x == a.x && y == a.y && z == a.z;
}
}r[90 * 90];
int main(){
int n,cntcase = 0;
while(~scanf("%d",&n) && n){
int a[3],cur = 1;
for(int i = 0 ;i < n ; ++i){
for(int j = 0;j < 3 ;++j) scanf("%d",&a[j]);
sort(a,a+3);
r[cur++] = mRect(a[0],a[1],a[2]);
r[cur++] = mRect(a[0],a[2],a[1]);
r[cur++] = mRect(a[1],a[2],a[0]);
}
sort(r+1,r+cur);
cur = unique(r+1,r+cur) - r;
memset(dp,0,sizeof(dp));
r[0] = mRect(0x3f3f3f3f,0x3f3f3f3f,0);
int maxh = 0;
for(int i = 1;i < cur;++i){
for(int j = 0;j < i;++j){
if(r[i].x < r[j].x && r[i].y < r[j].y){
dp[i] = max(dp[i],dp[j] + r[i].z);
}
}
maxh = max(maxh,dp[i]);
}
printf("Case %d: maximum height = %d\n",++cntcase,maxh);
}
return 0;
}
[2016-03-30][HDU][1069][Monkey and Banana]
标签:
原文地址:http://www.cnblogs.com/qhy285571052/p/4cf945a699f5de1d1c250acfd2a29dc6.html