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

1
10 20 30
2
6 8 10
5 5 5
7
1 1 1
2 2 2
3 3 3
4 4 4
5 5 5
6 6 6
7 7 7
5
31 41 59
26 53 58
97 93 23
84 62 64
33 83 27
0
Sample Output
Case 1: maximum height = 40
Case 2: maximum height = 21
Case 3: maximum height = 28
Case 4: maximum height = 342

题意如下

研究人员有n种类型的砖块,每种类型的砖块都有无限个。第i块砖块的长宽高分别用xi,yi,zi来表示。 同时,由于砖块是可以旋转的,每个砖块的3条边可以组成6种不同的长宽高。你的任务是编写一个程序,计算猴子们最高可以堆出的砖块们的高度。

思路如下

我们先结合题目去分析这一题:题目中给了很多种块,而每种砖块的给了三个参数分别是 xi,hi,zi 三个参数中的每个参数都可以作为高,剩下两个参数中,可以任选其中一个作为长,最后剩下的那个参数作为宽,这样每种砖就可以衍生出6种砖,所以虽然每种砖无限个,但是我们却每种砖只能用一个(因为摆放砖块的时候是严格递减的),

这一题我们可以把这题转化成求 最大递减子序列的和,只不过这里的 和与原来所求的和(原来求和是:子序列中的元素的值直接相加,而我们这题的是 子序列的中每个元素(即代表 一个砖块

C - Monkey and Banana的更多相关文章

  1. hdu 1069 Monkey and Banana

    Monkey and Banana Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others ...

  2. 杭电oj 1069 Monkey and Banana 最长递增子序列

    Monkey and Banana Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)To ...

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

    ---恢复内容开始--- Monkey and Banana Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K ...

  4. ACM-经典DP之Monkey and Banana——hdu1069

    ***************************************转载请注明出处:http://blog.csdn.net/lttree************************** ...

  5. HDU 1069 Monkey and Banana (DP)

    Monkey and Banana Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u S ...

  6. HDU 1069 Monkey and Banana(动态规划)

    Monkey and Banana Problem Description A group of researchers are designing an experiment to test the ...

  7. Monkey and Banana(HDU 1069 动态规划)

    Monkey and Banana Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others ...

  8. ZOJ 1093 Monkey and Banana (LIS)解题报告

    ZOJ  1093   Monkey and Banana  (LIS)解题报告 题目链接:http://acm.hust.edu.cn/vjudge/contest/view.action?cid= ...

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

    Monkey and Banana Problem Description A group of researchers are designing an experiment to test the ...

  10. Monkey and Banana(基础DP)

    Monkey and Banana Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others ...

随机推荐

  1. jenkins操作

    jenkins忘记用户名以及登录密码的解决方法 1.jenkins 根目录下找到config.xml,修改配置  <useSecurity>true</useSecurity> ...

  2. Linux环境下安装MySQL 5.7.28

    先进入MySQL官网: www.mysql.com 去下载安装包 进入DOWNLOADS选项,点击MySQL Community (GPL) Downloads. 点击进入MySQL Communit ...

  3. 基于osg的python三维程序开发(二)------向量

    上一篇文章展示了如何简单创建一个osg python 程序, 本篇展示了了一些基础数据结构的使用: from pyosg import * vec = osg.Vec3Array() #push ba ...

  4. SpringBoot+AOP构建多数据源的切换实践

    针对微服务架构中常用的设计模块,通常我们都会需要使用到druid作为我们的数据连接池,当架构发生扩展的时候 ,通常面对的数据存储服务器也会渐渐增加,从原本的单库架构逐渐扩展为复杂的多库架构. 当在业务 ...

  5. 你会无聊到把Administrator用户禁用,并且自己创建的用户搞到消失掉还有Administrator用户被禁吗。。。。。

    2020年3月17日20:07:00 如文章标题哈,就是这么任性,无奈 事件起因:因为要部署项目,并且需要将线上的Oracle数据库导入到本地Oracle数据库中突然发现使用 sqlplus 连接数据 ...

  6. js 面向对象 打气球小游戏

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...

  7. (转)GNU风格ARM汇编语法指南(非常详细)4

    原文地址:http://zqwt.012.blog.163.com/blog/static/12044684201011148226622/ 4.GNU汇编语言定义入口点 汇编程序的缺省入口是_sta ...

  8. 迷你记事本 https://vladocar.github.io/Minimal-Notes/

    迷你记事本 https://vladocar.github.io/Minimal-Notes/

  9. oracle--触发器(转)

    转载自http://blog.csdn.net/indexman/article/details/8023740/ 触发器是许多关系数据库系统都提供的一项技术.在oracle系统里,触发器类似过程和函 ...

  10. StringBuilder内存碎片对性能的影响

    StringBuilder内存碎片对性能的影响 TL;DR: StringBuilder内部是由多段char[]组成的半自动链表,因此频繁从中间修改StringBuilder,会将原本连续的内存分隔为 ...