Space Elevator POJ
来源:互联网 发布:国家承认网络教育 编辑:程序博客网 时间:2024/06/06 09:17
题目传送门
题意:给你n种高塔,每一种高塔都有自己的高度,数量,以及这种高塔组稿不能超过的高度,问你能搭建成的最高的高度。
思路:按照高塔的限制高度进行一个排序,然后多重背包就好了。
#include <algorithm>#include <cmath>#include <cstdio>#include <cstring>#include <iostream>#include <list>#include <map>#include <queue>#include <set>#include <stack>#include <string>#include <vector>#define MAXN 100100#define MAXE 100#define INF 100000000#define MOD 10001#define LL long long#define ULL unsigned long long#define pi 3.14159using namespace std;struct Node { int h; int a; int c;}p[MAXN];bool cmp(const Node &x1, const Node &x2) { return x1.a < x2.a;}int vis[MAXN];bool dp[MAXN];int main() { std::ios::sync_with_stdio(false); int n; cin >> n; int max_height = 0; for (int i = 1; i <= n; ++i) { cin >> p[i].h >> p[i].a >> p[i].c; max_height = max(max_height, p[i].a); } sort(p + 1, p + 1 + n, cmp); memset(dp, false, sizeof(dp)); dp[0] = true; for (int i = 1; i <= n; ++i) { memset(vis, 0, sizeof(vis)); for (int j = p[i].h; j <= p[i].a; ++j) { if (!dp[j] && dp[j - p[i].h] && vis[j - p[i].h] < p[i].c) { dp[j] = true; vis[j] = vis[j - p[i].h] + 1; } } } for (int i = max_height; i >= 0; --i) { if (dp[i]) { cout << i << endl; break; } } return 0;}/* */
阅读全文
0 0
- POJ 2392 Space Elevator
- poj Space Elevator
- poj 2392 Space Elevator
- POJ 2392 Space Elevator
- poj 2392 Space Elevator
- POJ 2392 Space Elevator
- poj 2392 Space Elevator
- POJ-2392-Space Elevator
- poj 2392 Space Elevator
- poj 2392--Space Elevator
- poj 2392 Space Elevator
- POJ Space Elevator
- POJ 2392 Space Elevator
- POJ 2392 Space Elevator
- poj 2392 Space Elevator
- poj 2392 Space Elevator
- poj 2392 space elevator
- POJ 2392 Space Elevator
- JS 时间戳转换成几天前
- Adnroid LearningNotes
- 关注程序性能(3) jvisualvm监视远程主机
- Android 5.1.1 时间同步方式
- CATIA DELMIA ENOVIA v5-6R2015 SP6 Update Only Win32_64 2CD
- Space Elevator POJ
- 【视频变化检测】2017CVPR Spatio-Temporal Self-Organizing Map Deep Network for Dynamic Object Detection from
- 用指向指针的指针的方法对n个整数进行排序。
- LightGBM原理简介
- JeeSite相关技术摘点(六)
- C#个人重构之登录
- 华硕FX53VD6700笔记本如何u盘装系统win7教程
- 提高代码健壮性
- 待整理