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. Nginx之负载均衡配置(一)

    前文我们聊了下nginx作为反向代理服务器,代理后端动态应用服务器的配置,回顾请参考https://www.cnblogs.com/qiuhom-1874/p/12430543.html:今天我们来聊 ...

  2. xcode制作越狱包

    1.将运行目标选为iOS Device 2.Edit Scheme -> 选择 Run [App Name] -> Build Configuration下拉框中选择Release 3.生 ...

  3. flask 设置https请求 访问flask服务器

    学习过程中想要学教程中一样,做个假的微信公众号推送,不过去了微信开发文档怎么一直说需要https的请求(教学中没有说需要https,一直是http) 但是我的服务器只能使用http请求访问,如果硬是要 ...

  4. 使用SharpDevelop配合MonoGame进行游戏开发

    SharpDevelop是一款开源的轻量级IDE,它支持众多的语言及项目开发.可以看看支持的项目. 程序本体仅十几MB,打开项目速度飞快. 目前SharpDevelop最高支持C# 5.0,.NET ...

  5. .Net Core 实现图片验证码

    记录自己的学习,参考了网上各位大佬的技术,往往在登录的时候需要使用到验证码来进行简单的一个校验,这边使用在.net core上进行生成图片二维码 思路很简单=> 生成一个随机数->保存到服 ...

  6. Natas2 Writeup(水平越权)

    Natas2: 查看源码,发现页面隐藏了一个图片的连接,分析图片,无隐写内容,联想到目录权限问题,访问同级目录http://natas2.natas.labs.overthewire.org/file ...

  7. VS2019 C++动态链接库的创建使用(4) - C语言客户端

    前面提到过C++具有函数重载功能,所以引出的函数名会有变化,即名称改编,如果是C语言编写的客户端则无法正确识别. 处理方法: ①只需在宏定义中间增加 extern "C",但这种使 ...

  8. Development of a High Coverage Pseudotargeted Lipidomics Method Based on Ultra-High Performance Liquid Chromatography−Mass Spectrometry(基于超高效液相色谱-质谱法的高覆盖拟靶向脂质组学方法的开发)

    文献名:Development of a High Coverage Pseudotargeted Lipidomics Method Based on Ultra-High Performance ...

  9. AndroiBugs Android漏洞扫描器

    Download Address:https://github.com/AndroBugs/AndroBugs_Framework Usage for Unix/Linux: ####To run t ...

  10. cmdb采集数据的版本

    在局部配置文件中配置MODE=' agent',或者MODE=‘ssh’,或者MODE=‘’saltstack ',  实现只需要修改这个配置,就会使用对应的方案进行采集数据 第一种版本: 启动文件中 ...