POJ 2392】的更多相关文章

POJ 2392 Space Elevator(贪心+多重背包) http://poj.org/problem?id=2392 题意: 题意:给定n种积木.每种积木都有一个高度h[i],一个数量num[i].另一个限制条件,这个积木所在的位置不能高于limit[i],问能叠起的最大高度? 分析: 本题是一道多重背包问题, 只是每一个物品的选择不只要受该种物品的数量num[i]限制, 且该物品还受到limit[i]的限制. 这里有一个贪心的结论: 我们每次背包选取物品时都应该优先放置当前limit…
题目链接: http://poj.org/problem?id=2392 题意: 给你k类方块,每类方块ci个,每类方块的高度为hi,现在要报所有的方块叠在一起,每类方块的任何一个部分都不能出现在ai以上的高度,问这些方块能叠的最高高度. 题解: 首先按ai升序排序,尽量让高度限制低的先排掉,如果不这样做一些转移会失效掉: 比如:h1=3,a1=3;h2=4,a2=7 如果先搭1再搭2则合法,但反过来则变成无效的转移了. 处理好顺序之后跑一遍背包就可以了,因为最大高度为40000,比较小,所以用…
Description The cows are going to space! They plan to achieve orbit by building a sort of space elevator: a giant tower of blocks. They have K ( <= K <= ) different types of blocks with which to build the tower. Each block of type i has height h_i (…
该题与POJ 1742的思路基本一致:http://www.cnblogs.com/sevenun/p/5442279.html(多重背包) 题意:给你n个电梯,第i个电梯高h[i],数量有c[i]个,但是每个电梯所在高度不能超过a[i]. 求问,怎么样的建造方案能够使电梯能够达到最大高度 思路:首先,必然要使电梯按a[i]进行排序,a[i]最小的电梯先建造.例如,电梯1,只能在高度20以下建造,而电梯2能在高度50以下建造,我当然先建造电梯1,否则如果先建造电梯2,就会导致我建造的高度早早超过…
Description The cows are going to space! They plan to achieve orbit by building a sort of space elevator: a giant tower of blocks. They have K (1 <= K <= 400) different types of blocks with which to build the tower. Each block of type i has height h…
太空电梯 题目大意:一群牛想造电梯到太空,电梯都是由一个一个块组成的,每一种块不能超过这个类型的高度,且每一种块都有各自的高度,有固定数量,问最高能造多高. 这题就是1742的翻版,对ai排个序就可以了 (尼玛,我qsort排了n-1个数,wa半天不知所措) #include <iostream> #include <functional> #include <algorithm> using namespace std; typedef struct _set { i…
题意:有几个砖,给出高度,能放的最大高度和数目,求这些砖能垒成的最大高度 依据lim排个序,按一层一层进行背包 #include<cstdio> #include<iostream> #include<algorithm> #include<cstring> #include<cmath> #include<queue> using namespace std; ; int n,m,t; int dp[maxn]; struct No…
多重背包.本题不须要二分优化.相对简单点.由于反复数十分小,小于10. 而添加一个限制每种材料的高度做法.假设使用逆向填表,那么仅仅须要从这个高度往小递归填表就能够了. 还有就是注意要排序,以限制高度为标准从小到大排序.否则答案错误的. #include <stdio.h> #include <string.h> #include <algorithm> using std::sort; const int MAX_K = 401; const int MAX_H =…
转自:http://blog.csdn.net/wangjian8006 题目大意:有一头奶牛要上太空,他有很多种石头,每种石头的高度是hi,但是不能放到ai之上的高度,并且这种石头有ci个将这些石头叠加起来,问能够达到的最高高度.解题思路:首先对数据进行升序排序,这样才是一个标准的多重背包的问题为什么要排序?因为只有这样才能得到最优解,如果一开始就是高的在前面,那么后面有低的却不能选到,就直接选高的去了.这样是不能达到最优解的使f[i]的状态标记,是否可以达到这个高度这样能够达到取f[i]中i…
#include <iostream> #include <algorithm> #define MAXN 40005 using namespace std; struct node { int a; int b; int c; }; node _m[]; bool mark[MAXN]; bool op(node a,node b); int main() { //freopen("acm.acm","r",stdin); int n;…