01背包--hdu2639】的更多相关文章

hdu-2639 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.h…
http://acm.hdu.edu.cn/showproblem.php?pid=2639 题意:给出一行价值,一行体积,让你在v体积的范围内找出第k大的值.......(注意,不要 和它的第一题混起来,它第一行是价值,再是体积) 思路:首先dp[i][j]代表的是在体积为i的时候第j优解为dp[i][j]......那么,我们就可以这样思考,i对应体积,那么如果只是一维的dp[i],代表的应该是体积为i时的最大值,那么同理,dp[i][1]代表的是体积为i时的最大值,那么我们就可以退出两种动…
Bone Collector II Time Limit: 5000/2000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 3437    Accepted Submission(s): 1773 Problem Description The title of this problem is familiar,isn't it?yeah,if you had took par…
题目http://acm.hdu.edu.cn/showproblem.php?pid=2639 分析:这是求第K大的01背包问题,很经典.dp[j][k]为背包里面装j容量时候的第K大的价值. 从普通01背包中可以知道最大价值dp[j]是由dp[j]和dp[j-c[i]]+w[i]决定的.那么可以知道 dp[j][k]也是有dp[j][k]和dp[j-c[i]][k]来决定的. 求次优解.第K优解: 对于求次优解.第K优解类的问题,如果相应的最优解问题能写出状态转移方程.用动态规划解决,那么求…
# include <stdio.h> # include <stdlib.h> # include <string.h> # define max(x,y) x>y?x:y; ];//价值 ];//重量 ][]; int main() { int n,m; while(scanf("%d%d",&m,&n)!=EOF) { memset(dp,,sizeof(dp));//初始化 ; i<=n; i++) scanf(&…
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…
题意:过山车有n个区域,一个人有两个值F,D,在每个区域有两种选择: 1.睁眼: F += f[i], D += d[i] 2.闭眼: F = F ,     D -= K 问在D小于等于一定限度的时候最大的F. 解法: 用DP来做,如果定义dp[i][j]为前 i 个,D值为j的情况下最大的F的话,由于D值可能会增加到很大,所以是存不下的,又因为F每次最多增加20,那么1000次最多增加20000,所以开dp[1000][20000],dp[i][j]表示前 i 个,F值为j的情况下最小的D.…
Team Them Up! Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 7608   Accepted: 2041   Special Judge Description Your task is to divide a number of persons into two teams, in such a way, that: everyone belongs to one of the teams; every t…
传送门 Description Hasan and Bahosain want to buy a new video game, they want to share the expenses. Hasan has a set of N coins and Bahosain has a set of M coins. The video game costs W JDs. Find the number of ways in which they can pay exactly W JDs su…
题目链接: http://www.51nod.com/onlineJudge/questionCode.html#!problemId=1085 题意: 中文题诶~ 思路: 01背包模板题. 用dp[i][j]表示到第i个物品花去j空间能存储的最大价值, 那么很显然有 ; i<=n; i++){ ; j<=m; j++){ //注意这里的j是从0开始而非a[i] if(j>=a[i]){ dp[i][j]=max(dp[i-][j-a[i]]+b[i], dp[i-][j]); }els…