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 ...
随机推荐
- Vue的模板内换行问题
在用vue的模板{{}}进行渲染文本时候,字符串换行不起作用,后使用ES6的模板字符串进行换行仍然不起作用,解决方法: <div>{{str}}</div> 可换为用v-htm ...
- PHP mysql事务问题实例分析
本文实例分析了PHP的mysql事务问题.分享给大家供大家参考,具体如下: 对于myisam数据库,可以控制事务的进行: $mysqlrl = mysql_connect ( $db_config [ ...
- 扫码枪读取条形码数据(vue)
扫码枪是模拟键盘输入的,所有事件为document.onkeypress = function(){}. 在vue项目中,是没有window.onload的,所以在created钩子函数中做: var ...
- juery 弹出框
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...
- Markdown试用
目录 今天又是充满希望的一天 一.是什么 二.为什么 三.怎么做 代码 这世界上好人坏人都很多,我不是一个坏人. 我不是个英雄,我只是个拿
- Ubuntu下搭建.Net Core环境并发布MVC项目
支撑环境 1. Windows 10 1809 12月更新版本(其他版本应该也行,但建议不低于1809,过低的版本可能无法安装子系统ubuntu18.04 LTS) 2. ubuntu 18.04 L ...
- 面向对象里is-a和has-a的含义
面向对象的核心思想是:抽象.封装.继承.多态.在实践中用的最多的术语就是 is a(是一个) ,和 has a(有一个).其实他们的意思很简单,对应面向对象设计中的两种形态继承.组合. 一.继承( i ...
- Integration of Metabolomics and Transcriptomics To Reveal Metabolic Characteristics and Key Targets Associated with Cisplatin Resistance in Nonsmall Cell Lung Cancer(解读人:林山云)
期刊名:J. Proteome Res 发表时间:(2019年8月) IF:3.78 单位: 上海第九人民医院药学系,上海交通大学药学院 上海交通大学药物与生物化学系 物种:人源A549细胞系 技 ...
- Python-时间戳、元组时间的格式、自定义时间格式之间的转换
一.时间戳.元组时间的格式.自定义时间格式之间的转换 1.下面是三者之间的转换关系: 2.代码如下: import time import datetime print(time.time()) #获 ...
- zabbix笔记_002
监控登录用户 监控图形配置 创建图形: 配置完成后查看图形: 创建触发器配置 创建完成后可以查看 监控磁盘IO I/O查看工具: istat 安装[需要epel源]: yum install -y s ...