HDU-1069-Monkey and Banana
链接:https://vjudge.net/problem/HDU-1069#author=prayerhgq
题意:
思路:
结构体记录每三个数可以形成的砖块,以长宽排序,从小到大遍历,将每个砖块上面能垒上去的高度叠加。
因为从小往大,之前的砖块都是能垒的最大高度。
代码:
#include <iostream>
#include <memory.h>
#include <string>
#include <istream>
#include <sstream>
#include <vector>
#include <stack>
#include <algorithm>
#include <map>
#include <queue>
#include <math.h>
#include <cstdio>
using namespace std;typedef long long LL;const int MAXN = 30 * 6 + 10;
const int INF = 0x7fffffff;struct Node
{int _x, _y;int _h;bool operator < (const Node & that) const {if (this->_x != that._x)return this->_x < that._x;return this->_y < that._y;}
}node[MAXN];int main()
{int n;int a, b, c;int cnt = 1;while (cin >> n && n){int pos = 0;for (int i = 1;i <= n;i++){cin >> a >> b >> c;pos++, node[pos]._x = a, node[pos]._y = b, node[pos]._h = c;pos++, node[pos]._x = a, node[pos]._y = c, node[pos]._h = b;pos++, node[pos]._x = b, node[pos]._y = a, node[pos]._h = c;pos++, node[pos]._x = b, node[pos]._y = c, node[pos]._h = a;pos++, node[pos]._x = c, node[pos]._y = a, node[pos]._h = b;pos++, node[pos]._x = c, node[pos]._y = b, node[pos]._h = a;}sort(node + 1, node + 1 + pos);int res = node[1]._h;for (int i = 1;i <= pos;i++){int tmp = 0;for (int j = 1;j < i;j++){if (node[j]._x < node[i]._x && node[j]._y < node[i]._y)tmp = max(tmp, node[j]._h);}node[i]._h += tmp;res = max(res, node[i]._h);}printf("Case %d: maximum height = %d\n", cnt++, res);}return 0;
}
转载于:https://www.cnblogs.com/YDDDD/p/10354927.html
HDU-1069-Monkey and Banana相关推荐
- HDU 1069 Monkey and Banana 最长上升子序列进阶(动态规划)
HDU 1069(动态规划) Monkey and Banana Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K ...
- HDU 1069 Monkey and Banana(简单图解,经典DP,最大上升子序列变形)
题目链接 今天做的第二题,感觉比较经典,详细记录一下吧! Monkey and Banana Time Limit: 2000/1000 MS (Java/Others) Memory Limit: ...
- 三维最长上升子序列问题——HDU 1069 Monkey and Banana
题目: A group of researchers are designing an experiment to test the IQ of a monkey. They will hang a ...
- hdu 1069 Monkey and Banana (LIS)
Problem - 1069 随便找到的一道题目. 题意是给出一些的长方体,长方体可以用任意次数,可以任意翻转.如果一个长方体可以叠在另一个长方体上,条件是这个长方体的长和宽严格小于另一个长方体的长和 ...
- hdu(1069)——Monkey and Banana(LIS变形)
题意: 如今给你n个石块,然后它由坐标来表示(x,y,z).可是它能够有不同的方法,也就是说它的三个坐标能够轮换着来的. 石块的数量不限,可是每次都必须保持上底面的长和宽严格递减,然后问你用这些石块所 ...
- HDU 1069 Monkey and Banana
传送门 #include<iostream> #include<algorithm> #include<map> #include<set> #incl ...
- hdu 1069 Monkey and Banana 【动态规划】
题目 题意:研究人员要测试猴子的IQ,将香蕉挂到一定高度,给猴子一些不同大小的箱子,箱子数量不限,让猩猩通过叠长方体来够到香蕉. 现在给你N种长方体, 要求:位于上面的长方体的长和宽 要小于 下面 ...
- hdu 1069 Monkey and Banana dp
题意:给你n种个长方体,告诉你每种长方体的长,宽,高,并且每种长方体个数不限 问:把它们堆起来的最大高度 限制条件:上面一个长方体a的底面积,必须比它下面一个长方体b的底面积大,而且,a的底面的长宽也 ...
- HDUOJ 1069 Monkey and Banana
HDUOJ 1069 Monkey and Banana 题目链接 Problem Description A group of researchers are designing an experi ...
- HDOJ 1069 Monkey and Banana
1:每一组X,Y,Z对应3个立方体 2:按面积从小到大DP Monkey and Banana Time Limit: 2000/1000 MS (Java/Others) Memory Lim ...
最新文章
- ZenHub已集成于GitHub企业版
- C语言再学习 -- 再论内存管理
- CDOJ 486 Good Morning 傻逼题
- 响铃:Don't be evil?Google别闹了
- [css] 用css3画出一个立体魔方
- div css入门教程,更简洁CSS清理浮动方式:clearfix
- struct多种声明定义写法的小结
- (43)System Verilog 类中变量随机化
- .NET并行编程实践(一:.NET并行计算基本介绍、并行循环使用模式)
- 第4节 常见软件安装-Mysql和SQLyog
- 十大免费SSL证书:网站免费添加HTTPS加密
- Linux下关闭udhcpc客户端时,通知服务器释放租约
- html5网页宠物窝,11款融进家装的宠物窝设计 简直萌翻了!!
- 配置远程运行后提示,/usr/bin/python: can‘t open file ‘xxxx‘: [Errno 2] No such file or directory
- html最全知识点(超级详细)
- 小程序----页面配置
- 大番茄插件 常用配置
- DL之pix2pix:pix2pix(cGAN)自动上色算法的简介(论文介绍)、架构详解、案例应用等配图集合之详细攻略
- 数据包络分析模型--收费公告
- ROS ERROR: cannot launch node of type [mbot_teleop/mbot_teleop.py]
热门文章
- python映射类型-python 基础学习 — 映射类型:字典
- python绘制三维曲面图-python中Matplotlib实现绘制3D图的示例代码
- python2.7爬虫实例-用案例让你一文搞懂python网络爬虫
- 从零开始学python数据分析-【01】从零开始学Python—数据分析与挖掘概述
- python怎么导入txt文件夹-python读取一个目录下所有txt里面的内容方法
- 老师学python可以干嘛-学 Python 都用来干嘛的?
- linux下载哪个python版本-Linux下切换Python版本的几种方法
- python编程入门经典实例-【python】编程语言入门经典100例--30
- python经典案例-Python经典实例
- python中and与or的执行顺序-python 代码运行顺序问题?