日韩av黄I国产麻豆传媒I国产91av视频在线观看I日韩一区二区三区在线看I美女国产在线I麻豆视频国产在线观看I成人黄色短片

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 >

HDOJ 1069 Monkey and Banana

發布時間:2025/7/14 33 豆豆
生活随笔 收集整理的這篇文章主要介紹了 HDOJ 1069 Monkey and Banana 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

1:每一組X,Y,Z對應3個立方體
2:按面積從小到大DP

Monkey and Banana

Time Limit: 2000/1000 MS (Java/Others)????Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 5356????Accepted Submission(s): 2744


Problem Description A group of researchers are designing an experiment to test the IQ of a monkey. They will hang a banana at the roof of a building, and at the mean time, provide the monkey with some blocks. If the monkey is clever enough, it shall be able to reach the banana by placing one block on the top another to build a tower and climb up to get its favorite food.

The researchers have n types of blocks, and an unlimited supply of blocks of each type. Each type-i block was a rectangular solid with linear dimensions (xi, yi, zi). A block could be reoriented so that any two of its three dimensions determined the dimensions of the base and the other dimension was the height.?

They want to make sure that the tallest tower possible by stacking blocks can reach the roof. The problem is that, in building a tower, one block could only be placed on top of another block as long as the two base dimensions of the upper block were both strictly smaller than the corresponding base dimensions of the lower block because there has to be some space for the monkey to step on. This meant, for example, that blocks oriented to have equal-sized bases couldn't be stacked.?

Your job is to write a program that determines the height of the tallest tower the monkey can build with a given set of blocks.

?

Input The input file will contain one or more test cases. The first line of each test case contains an integer n,
representing the number of different blocks in the following data set. The maximum value for n is 30.
Each of the next n lines contains three integers representing the values xi, yi and zi.
Input is terminated by a value of zero (0) for n.

?

Output For each test case, print one line containing the case number (they are numbered sequentially starting from 1) and the height of the tallest possible tower in the format "Case case: maximum height = height".

?

Sample Input 110 20 3026 8 105 5 571 1 12 2 23 3 34 4 45 5 56 6 67 7 7531 41 5926 53 5897 93 2384 62 6433 83 270

?

Sample Output Case 1: maximum height = 40Case 2: maximum height = 21Case 3: maximum height = 28Case 4: maximum height = 342

?

Source University of Ulm Local Contest 1996

?

Recommend JGShining 1 #include <iostream> 2 #include <algorithm> 3 #include <cstring> 4 5 using namespace std; 6 7 struct cube 8 { 9 int l,w,h; 10 int sum; 11 }cc[111]; 12 13 bool ifso(cube a,cube b) 14 { 15 return (a.l<b.l&&a.w<b.w)||(a.w<b.l&&a.l<b.w); 16 } 17 18 bool cmp(cube a,cube b) 19 { 20 return a.l*a.w>b.l*b.w; 21 } 22 23 int main() 24 { 25 int n; 26 int cnt=1; 27 while(cin>>n&&n) 28 { 29 memset(cc,0,sizeof(cc)); 30 for(int i=0;i<3*n;i++) 31 { 32 int L,W,H; 33 cin>>L>>W>>H; 34 cc[i].l=L;cc[i].w=W;cc[i].h=H;cc[i].sum=0;i++; 35 cc[i].l=W;cc[i].w=H;cc[i].h=L;cc[i].sum=0;i++; 36 cc[i].l=H;cc[i].w=L;cc[i].h=W;cc[i].sum=0; 37 } 38 39 sort(cc,cc+3*n,cmp); 40 41 for(int i=0;i<3*n;i++) 42 { 43 int temx=0; 44 for(int j=0;j<i;j++) 45 { 46 if(cc[j].sum>temx&&ifso(cc[i],cc[j])) 47 temx=cc[j].sum; 48 } 49 cc[i].sum=temx+cc[i].h; 50 } 51 52 int ans=-1; 53 for(int i=0;i<3*n;i++) 54 { 55 ans=max(ans,cc[i].sum); 56 } 57 58 cout<<"Case "<<cnt++<<": maximum height = "<<ans<<endl; 59 } 60 61 return 0; 62 }

?

轉載于:https://www.cnblogs.com/CKboss/archive/2013/05/24/3097742.html

總結

以上是生活随笔為你收集整理的HDOJ 1069 Monkey and Banana的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。