[2016-03-30][HDU][1069][Monkey and Banana]

  • 时间:2016-03-27 15:19:40 星期日

  • 题目编号:[2016-03-30][HDU][1069][Monkey and Banana]

  • 题目大意:给定n种积木无限个,问这些积木最大能叠多高,上面的积木长宽必须严格小于下面的积木

  • 分析:

    • dp[i]表示第i个积木在顶部时候的最大高度,那么dp[i] = max(dp[i],dp[j] + h[i]);?ji能放在j上面?ji能放在j上面
    • 初始条件就是长宽最大的高度是它自己,
  1. #include <algorithm>
  2. #include <cstring>
  3. #include <cstdio>
  4. using namespace std;
  5. typedef long long LL;
  6. int dp[90*90];
  7. struct mRect{
  8. int x,y,z;
  9. mRect(int a = 0,int b = 0,int c = 0):x(a),y(b),z(c){};
  10. bool operator < (const mRect & a)const{
  11. return x > a.x || (x == a.x && y > a.y) || (x == a.x && y == a.y && z > a.z);
  12. }
  13. bool operator == (const mRect & a)const{
  14. return x == a.x && y == a.y && z == a.z;
  15. }
  16. }r[90 * 90];
  17. int main(){
  18. int n,cntcase = 0;
  19. while(~scanf("%d",&n) && n){
  20. int a[3],cur = 1;
  21. for(int i = 0 ;i < n ; ++i){
  22. for(int j = 0;j < 3 ;++j) scanf("%d",&a[j]);
  23. sort(a,a+3);
  24. r[cur++] = mRect(a[0],a[1],a[2]);
  25. r[cur++] = mRect(a[0],a[2],a[1]);
  26. r[cur++] = mRect(a[1],a[2],a[0]);
  27. }
  28. sort(r+1,r+cur);
  29. cur = unique(r+1,r+cur) - r;
  30. memset(dp,0,sizeof(dp));
  31. r[0] = mRect(0x3f3f3f3f,0x3f3f3f3f,0);
  32. int maxh = 0;
  33. for(int i = 1;i < cur;++i){
  34. for(int j = 0;j < i;++j){
  35. if(r[i].x < r[j].x && r[i].y < r[j].y){
  36. dp[i] = max(dp[i],dp[j] + r[i].z);
  37. }
  38. }
  39. maxh = max(maxh,dp[i]);
  40. }
  41. printf("Case %d: maximum height = %d\n",++cntcase,maxh);
  42. }
  43. return 0;
  44. }

来自为知笔记(Wiz)

时间: 2024-12-13 07:08:12

[2016-03-30][HDU][1069][Monkey and Banana]的相关文章

HDU 1069 Monkey and Banana(DP 长方体堆放问题)

Monkey and Banana 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

HDU 1069 Monkey and Banana (动规)

Monkey and Banana Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 7248    Accepted Submission(s): 3730 Problem Description A group of researchers are designing an experiment to test the IQ of a

HDU 1069 Monkey and Banana dp 题解

HDU 1069 Monkey and Banana 题解 纵有疾风起 题目大意 一堆科学家研究猩猩的智商,给他M种长方体,每种N个.然后,将一个香蕉挂在屋顶,让猩猩通过 叠长方体来够到香蕉. 现在给你M种长方体,计算,最高能堆多高.要求位于上面的长方体的长要大于(注意不是大于等于)下面长方体的长,上面长方体的宽大于下面长方体的宽. 输入输出 开始一个数n,表示有多少种木块,木块的数量无限,然后接下来的n行,每行3个数,是木块的长宽高三个参量 输出使用这些在满足条件的情况下能够摆放的最大高度 解

HDU 1069 Monkey and Banana(二维偏序LIS的应用)

---恢复内容开始--- Monkey and Banana Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 13003    Accepted Submission(s): 6843 Problem Description A group of researchers are designing an experiment to te

HDU 1069 Monkey and Banana 基础DP

题目链接:Monkey and Banana 大意:给出n种箱子的长宽高.每种不限个数.可以堆叠.询问可以达到的最高高度是多少. 要求两个箱子堆叠的时候叠加的面.上面的面的两维长度都严格小于下面的. 简单的DP,依然有很多地发给当时没想到.比如优先级,比如这么简单粗暴的选择. 1 /* 2 大意是.给出n种箱子的长宽高.每种不限个数.可以堆叠.询问可以达到的最高高度是多少. 3 要求两个箱子堆叠的时候叠加的面.上面的面的两维长度都严格小于下面的. 4 5 样例: 6 10 20 30 7 10

HDU 1069 Monkey and Banana LCS变形

点击打开链接题目链接 Monkey and Banana Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 7617    Accepted Submission(s): 3919 Problem Description A group of researchers are designing an experiment to test

hdu 1069 Monkey and Banana (结构体排序,也属于简单的dp)

Monkey and Banana Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 7770    Accepted Submission(s): 4003 Problem Description A group of researchers are designing an experiment to test the IQ of a

DP [HDU 1069] Monkey and Banana

Monkey and Banana Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 7854    Accepted Submission(s): 4051 Problem Description A group of researchers are designing an experiment to test the IQ of a

HDU 1069 Monkey and Banana(最大的单调递减序列啊 dp)

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1069 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 so