hdoj--1069 Monkey and Banana(dp)
2016-03-29 18:28
441 查看
hdoj 1069
题解
按面积排序,LIS.#include <iostream> #include <vector> #include <fstream> #include <algorithm> using namespace std; struct block{ int x, y, z; block(int x, int y, int z):x(x), y(y), z(z){} }; vector<block> vec; int cmp(const block& a, const block& b) { return a.x * a.y < b.x * b.y; } inline void append(int x, int y, int z) { vec.push_back(block(x, y, z)); vec.push_back(block(x, z, y)); vec.push_back(block(y, x, z)); vec.push_back(block(y, z, x)); vec.push_back(block(z, x, y)); vec.push_back(block(z, y, x)); } int main() { #ifdef LOCAL fstream cin("data.in"); #endif // LOCAL ios::sync_with_stdio(0); cin.tie(0); int kcase = 0; int n; while(cin >> n && n) { vec.clear(); int x, y, z; for(int i = 0; i < n; ++i) { cin >> x >> y >> z; append(x, y, z); } sort(vec.begin(), vec.end(), cmp); int dp[vec.size()]; int ans = 0; for(int i = 0; i < (int)vec.size(); ++i) { dp[i] = vec[i].z; for(int j = 0; j < i; ++j) if(vec[i].x > vec[j].x && vec[i].y > vec[j].y) dp[i] = max(dp[i], dp[j] + vec[i].z); ans = max(ans, dp[i]); } cout << "Case " << ++kcase <<": maximum height = " << ans << endl; } return 0; }
相关文章推荐
- RM格式压缩电影软件 Easy RealMedia Producer Full V1.94 下载
- 在IE 浏览器中使用 jquery的fadeIn() 效果 英文字符字体加粗
- 比较简单的jquery教程 Easy Ajax with jQuery 中文版全集第1/3页
- Easy RM RMVB to DVD Burner v1.3.8 汉化版 下载 附注册码
- 详解Android应用中屏幕尺寸的获取及dp和px值的转换
- 基于Android中dp和px之间进行转换的实现代码
- Android中dip、dp、sp、pt和px的区别详解
- Expandable "Detail" Table Rows
- linux下安装easy_install的方法
- LFC1.0.0 版本发布
- 归纳整理文件Easy Duplicate Finder2.24 破解版
- DM*** and Easy *** Server with ISAKMP Profiles
- easy ***
- cisco packet tracer 5.3 实现基于3A的easy ***
- Android px、dp、sp之间相互转换
- HP data protector软件学习1--基本角色与基本工作流程
- HP data protector软件学习2--软件组成与界面介绍
- android中像素单位dp、px、pt、sp的比较
- [Leetcode题目]19. Remove Nth Node From End of List
- [Leetcode题目]21. Merge Two Sorted Lists