标签:des style blog http java color
Monkey and Banana
Time
Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K
(Java/Others)
Total
Submission(s): 6866 Accepted Submission(s):
3516
1 #include <iostream> 2 #include <algorithm> 3 using namespace std; 4 5 typedef struct rectangular{ 6 int x,y,z; 7 }R; 8 R r[105]; 9 int k; 10 bool cmp(R a,R b) 11 { 12 if(a.x == b.x) 13 return a.y<b.y; 14 return a.x<b.x; 15 } 16 int dp() 17 { 18 int i, j; 19 int dp[105]; 20 sort(r,r+k,cmp); 21 int maxheight = 0; 22 for(i=0; i<k; i++) 23 { 24 dp[i] = r[i].z; 25 for(j=0;j<i; j++) 26 if(r[i].x>r[j].x && r[i].y>r[j].y) 27 if(dp[j]+r[i].z > dp[i]) 28 dp[i] = dp[j]+r[i].z; 29 if(maxheight < dp[i]) 30 maxheight = dp[i]; 31 } 32 return maxheight; 33 } 34 int main() 35 { 36 int n, i, cas=1; 37 int x, y, z; 38 while(cin>>n && n) 39 { 40 k = 0; 41 for(i=0; i<n; i++) 42 { 43 cin>>x>>y>>z; 44 r[k].x = max(x,y); 45 r[k].y = min(x,y); 46 r[k++].z = z; 47 r[k].x = max(x,z); 48 r[k].y = min(x,z); 49 r[k++].z = y; 50 r[k].x = max(y,z); 51 r[k].y = min(y,z); 52 r[k++].z = x; 53 } 54 cout<<"Case "<<cas++<<": maximum height = "<<dp()<<endl; 55 } 56 return 0; 57 }
杭电oj 1069 Monkey and Banana,码迷,mamicode.com
标签:des style blog http java color
原文地址:http://www.cnblogs.com/yazhou/p/3698923.html