题意: 01背包,找出第k最优解 题解: 对于01背包最优解我们肯定都很熟悉 第k最优解的话也就是在dp方程上加一个维度来存它的第k最优解(dp[i][j]代表,体积为i能获得的第j最大价值) 对于每一个物品只有两种选择情况 1.把这个物品加入背包 2.不要这个物品 那么它的前k种最优解也是由n种物品的这两个选择组成的 假设总体积是4,现在有两种物品,求第2最大值 1.体积1,价值3 2.体积1,价值2 最开始dp状态: 体积:   1  2  3  4 第1最大值:0  0  0  0 第2最…
http://acm.hdu.edu.cn/showproblem.php?pid=2639 http://blog.csdn.net/lulipeng_cpp/article/details/7584981 求第K大的思路是把每个d[v]看成是由d[v]和d[v-cost]+weight两个序列组成的,然后分别记录每个序列的第k大,然后逐项更新. 用个形象的比喻吧:如果我想知道学年最高分,那么,我只要知道每个班级的最高分,然后统计一遍就可以了. 如果我想知道学年前十呢?我必须要知道每个班的前十…
http://acm.hdu.edu.cn/showproblem.php?pid=2639 01背包第k优解,把每次的max分步列出来即可 #include<stdio.h> #include<string.h> #include<algorithm> using namespace std; struct Node { int price; int val; }node[]; int main() { int T; scanf("%d",&…
Bone Collector II Time Limit: 5000/2000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 3718    Accepted Submission(s): 1903 Problem Description The title of this problem is familiar,isn't it?yeah,if you had took par…
题意:收藏骨头. 思路: 常规的01背包. #include <iostream> #define N 1005 using namespace std; int volume[N]; //体积 int value[N]; //价值 int dp[N]; //总价值(动态更新) int max(int a,int b) { return a>b?a:b; } void cal(int n,int v) //不断更新数组dp { int i,j; ;i<=n;i++) ;j--) d…
题目链接 http://acm.hdu.edu.cn/showproblem.php?pid=2602 题意 有n块骨头,每块骨头体积为volume,价值为value,还有一个容量为v的背包,现在将骨头装入背包中,求所装入骨头价值的最大值. 思路 01背包问题,使用动态规划解决. 代码 #include <algorithm> #include <iostream> #include <cstring> #include <cstdio> using nam…
Bone Collector II Time Limit: 5000/2000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 4739    Accepted Submission(s): 2470 Problem Description The title of this problem is familiar,isn't it?yeah,if you had took pa…
Bone Collector II Time Limit: 5000/2000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 3355    Accepted Submission(s): 1726 Problem Description The title of this problem is familiar,isn't it?yeah,if you had took par…
The title of this problem is familiar,isn't it?yeah,if you had took part in the "Rookie Cup" competition,you must have seem this title.If you haven't seen it before,it doesn't matter,I will give you a link: Here is the link: http://acm.hdu.edu.c…
Bone Collector II Time Limit: 5000/2000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 4178    Accepted Submission(s): 2174 Problem Description The title of this problem is familiar,isn't it?yeah,if you had took pa…