标签:
题目:这里
题意:
Description
Input
Output
Sample Input
Sample Output
1 #include<cstdio> 2 #include<cstring> 3 #include<iostream> 4 #include<algorithm> 5 #include<cmath> 6 #include<string> 7 using namespace std; 8 9 struct node{ 10 int h,v,l; 11 }re[200]; 12 int dp[200]; 13 14 int max(int x,int y) {return x>y?x:y;} 15 16 bool cmp(node a,node b) 17 { 18 if (a.l==b.l) 19 { 20 if (a.v==b.v) 21 return a.h>b.h; 22 return a.v>b.v; 23 } 24 return a.l>b.l; 25 } 26 27 int main() 28 { 29 int n,tem=0; 30 while (~scanf("%d",&n)&&n) 31 { 32 int cas=0; 33 for (int i=1 ; i<=n ; i++) 34 { 35 int x,y,z; 36 scanf("%d%d%d",&x,&y,&z); 37 re[++cas].l=x,re[cas].h=y,re[cas].v=z; 38 re[++cas].l=z,re[cas].h=y,re[cas].v=x; 39 re[++cas].l=x,re[cas].h=z,re[cas].v=y; 40 re[++cas].l=y,re[cas].h=z,re[cas].v=x; 41 re[++cas].l=z,re[cas].h=x,re[cas].v=y; 42 re[++cas].l=y,re[cas].h=x,re[cas].v=z; 43 } 44 sort(re+1,re+cas+1,cmp); 45 for (int i=1 ; i<=cas ; i++) 46 { 47 dp[i]=re[i].h; 48 for (int j=1 ; j<i ; j++) 49 { 50 if (re[i].l<re[j].l&&re[i].v<re[j].v) 51 dp[i]=max(dp[i],dp[j]+re[i].h); 52 } 53 } 54 int ans=0; 55 for (int i=1 ; i<=cas ; i++) 56 ans=max(ans,dp[i]); 57 printf("Case %d: maximum height = %d\n",++tem,ans); 58 } 59 return 0; 60 }
hdu 1069 (DP) Monkey and Banana
标签:
原文地址:http://www.cnblogs.com/JJCHEHEDA/p/5768965.html