C - Monkey and Banana
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的更多相关文章
- hdu 1069 Monkey and Banana
Monkey and Banana Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others ...
- 杭电oj 1069 Monkey and Banana 最长递增子序列
Monkey and Banana Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)To ...
- HDU 1069 Monkey and Banana(二维偏序LIS的应用)
---恢复内容开始--- Monkey and Banana Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K ...
- ACM-经典DP之Monkey and Banana——hdu1069
***************************************转载请注明出处:http://blog.csdn.net/lttree************************** ...
- HDU 1069 Monkey and Banana (DP)
Monkey and Banana Time Limit:1000MS Memory Limit:32768KB 64bit IO Format:%I64d & %I64u S ...
- HDU 1069 Monkey and Banana(动态规划)
Monkey and Banana Problem Description A group of researchers are designing an experiment to test the ...
- Monkey and Banana(HDU 1069 动态规划)
Monkey and Banana Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others ...
- ZOJ 1093 Monkey and Banana (LIS)解题报告
ZOJ 1093 Monkey and Banana (LIS)解题报告 题目链接:http://acm.hust.edu.cn/vjudge/contest/view.action?cid= ...
- HDU 1069 Monkey and Banana(DP 长方体堆放问题)
Monkey and Banana Problem Description A group of researchers are designing an experiment to test the ...
- Monkey and Banana(基础DP)
Monkey and Banana Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others ...
随机推荐
- nowcoder 135F 圆
链接:https://www.nowcoder.com/acm/contest/135/F来源:牛客网 圆(circle) 时间限制:C/C++ 1秒,其他语言2秒 空间限制:C/C++ 3276 ...
- .Net Core WebApi在Linux上启动和关闭
测试机器:阿里云云主机1核2g 安装环境:centos-7 服务器:Nginx 1.17.1 测试默认已启动 已安装配置:.Net Core 3.1 测试默认安装 连接配置:x-ftp,x-shell ...
- go中处理各种请求方式以及处理接口请求参数
话不多说直接上代码,解读内容全部在代码中 1.处理请求方式 package main import ( "fmt" "io/ioutil" "net/ ...
- Vue2.0 【第一季】第6节 v-model指令
目录 Vue2.0 [第一季] 第6节 v-model指令 第6节 v-model指令 一.一个最简单的双向数据绑定代码: 二.修饰符 三.文本区域加入数据绑定 四.多选按钮绑定一个值 五.多选绑定一 ...
- Jenkins的凭证管理
Jenkins的凭证管理 什么是凭证? 凭证(cridential)是Jenkins进行受限操作时的凭据.比如使用SSH登录远程机器时,用户名和密码或SSH key就是凭证.而这些凭证不可能以明文写在 ...
- 【Weiss】【第03章】练习3.2
[练习3.2] 给你一个链表L和另一个链表P,它们包含以升序排列的整数.操作printlots(L,P)将打印L中那些由P所指定的位置上的元素. 例如,如果p=1,3,4,6,那么,L的第一.第三.第 ...
- 264. 丑数 II
编写一个程序,找出第 n 个丑数. 丑数就是只包含质因数 2, 3, 5 的正整数. 示例: 输入: n = 10输出: 12解释: 1, 2, 3, 4, 5, 6, 8, 9, 10, 12 是前 ...
- Servlet(简介,请求参数,页面跳转,生命周期,创建,配置,ServletContext,线程)
1.Servlet简介 servlet是java servlet的简称,称为小服务程序或服务连接器,用Java编写的服务器端程序, 主要功能在于交互式浏览和修改数据,生成动态的web内容 服务端运行的 ...
- 告别炼丹,Google Brain提出强化学习助力Neural Architecture Search | ICLR2017
论文为Google Brain在16年推出的使用强化学习的Neural Architecture Search方法,该方法能够针对数据集搜索构建特定的网络,但需要800卡训练一个月时间.虽然论文的思路 ...
- socket基本语法和粘包
一.基本语法 127.0.0.1 是本地回环地址 客户端 ...