Bone Collector

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 40598    Accepted Submission(s):
16872

Problem Description
Many years ago , in Teddy’s hometown there was a man
who was called “Bone Collector”. This man like to collect varies of bones , such
as dog’s , cow’s , also he went to the grave …
The bone collector had a big
bag with a volume of V ,and along his trip of collecting there are a lot of
bones , obviously , different bone has different value and different volume, now
given the each bone’s value along his trip , can you calculate out the maximum
of the total value the bone collector can get ?
 
Input
The first line contain a integer T , the number of
cases.
Followed by T cases , each case three lines , the first line contain
two integer N , V, (N <= 1000 , V <= 1000 )representing the number of
bones and the volume of his bag. And the second line contain N integers
representing the value of each bone. The third line contain N integers
representing the volume of each bone.
 
Output
One integer per line representing the maximum of the
total value (this number will be less than 231).
 
Sample Input
1
5 10
1 2 3 4 5
5 4 3 2 1
 
Sample Output
14
 
Author
Teddy
 
Source
 
Recommend
lcy   |   We have carefully selected several similar
problems for you:  1203 2159 2955 1171 2191 
 #include<cstdio>
#include<cstring>
#include<iostream>
#include<stack>
#include<set>
#include<map>
#include<queue>
#include<algorithm>
using namespace std;
#define max(a,b) (a>b?a:b)
int va[],vo[],dp[][];
int main()
{
//freopen("D:\\INPUT.txt","r",stdin);
int t,i,j;
int n,v;
scanf("%d",&t);
while(t--)
{
scanf("%d %d",&n,&v);
for(i=; i<=n; i++)
{
scanf("%d",&va[i]);
}
for(i=; i<=n; i++)
{
scanf("%d",&vo[i]);
}
//dp[i][j] 前i件物品放入j体积的价值的最大值
//dp[i][j]=max(dp[i-1][j],dp[i-1][j-vo[i]]+va[i])
for(i=; i<=n; i++) //i体积
{
for(j=; j<=v; j++)
{
if(j>=vo[i]){
dp[i][j]=max(dp[i-][j],dp[i-][j-vo[i]]+va[i]);
}
else{
dp[i][j]=dp[i-][j];
} //cout<<i<<" "<<j<<" "<<dp[i][j]<<endl;
}
}
printf("%d\n",dp[n][v]);
}
return ;
}

hduoj 2602Bone Collector的更多相关文章

  1. HDU——2602Bone Collector(01背包)

    Bone Collector Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) T ...

  2. HDU 2602Bone Collector 01背包问题

    题意:给出一个t代表有t组数据,然后给出n,n代表有n种石头,v代表旅行者的背包容量,然后给出n种石头的价值和容量大小,求能带走的最大价值 思路:01背包问题,每种石头只有拿与不拿两种状态.(其实我是 ...

  3. hduoj 1455 && uva 243 E - Sticks

    http://acm.hdu.edu.cn/showproblem.php?pid=1455 http://uva.onlinejudge.org/index.php?option=com_onlin ...

  4. The The Garbage-First (G1) collector since Oracle JDK 7 update 4 and later releases

    Refer to http://www.oracle.com/technetwork/tutorials/tutorials-1876574.html for detail. 一些内容复制到这儿 Th ...

  5. hdu 2602 Bone Collector(01背包)模板

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2602 Bone Collector Time Limit: 2000/1000 MS (Java/Ot ...

  6. Jmeter plugin jp@gc - PerfMon Metrics Collector

    Jmeter由于是开源工具,所以目前有很多插件可以供使用,最简单的方法是先把Plugin Manager安装了 下载地址:https://jmeter-plugins.org/wiki/Plugins ...

  7. Spring AOP 开发中遇到问题:Caused by: java.lang.IllegalArgumentException: warning no match for this type name: com.xxx.collector.service.impl.XxxServiceImpl [Xlint:invalidAbsoluteTypeName]

    在网上找了很多,都不是我想要的,后来发现是我在springaop注解的时候 写错了类名导致的这个问题 @Pointcut("execution(* com.xxx.collector.ser ...

  8. HDU2639Bone Collector II[01背包第k优值]

    Bone Collector II Time Limit: 5000/2000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others ...

  9. HDOJ 4336 Card Collector

    容斥原理+状压 Card Collector Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/O ...

随机推荐

  1. jquery文件上传控件 Uploadify 可以和ajax交互

    http://www.cnblogs.com/mofish/archive/2012/11/30/2796698.html  原网址 基于jquery的文件上传控件,支持ajax无刷新上传,多个文件同 ...

  2. 课后作业 利用for循环嵌出菱形

    for (int i = 1; i <= 11; i++) // i 的起始值是一 在<=11; 逐个递增 { int a, b, c;// 定义abc三数 for (a = 11; a ...

  3. C++: I/O流详解(二)——输入输出格式控制

    一.格式控制 ios提供直接设置标志字的控制格式函数 iostream和iomanip库还提供了一批控制符简化I/O格式化操作 状态标志 值 含义 输入/输出 skipws 0X0001 跳过输入中的 ...

  4. 在ubuntu 14.04 编译android 2.3.1 错误解决办法

    首先必须降低gcc版本: sudo apt-get install gcc-4.4sudo apt-get install g++-4.4sudo rm -rf /usr/bin/gcc /usr/b ...

  5. (转)Haar-like矩形遍历检测窗口演示Matlab源代码

    from:http://blog.sina.com.cn/s/blog_736aa0540101kzqb.html clc; clear; close all; % Haar-like特征矩形计算 b ...

  6. 【51nod1847】奇怪的数学题(Min_25筛+杜教筛)

    题面 传送门 题解 这题有毒--不知为啥的错误调了半天-- 令\(f(i)={sgcd(i)}\),那么容易看出\(f(i)\)就是\(i\)的次大质因子,用\(i\)除以它的最小质因子即可计算 于是 ...

  7. P1903 [国家集训队]数颜色 / 维护队列 带修改的莫队

    \(\color{#0066ff}{ 题目描述 }\) 墨墨购买了一套N支彩色画笔(其中有些颜色可能相同),摆成一排,你需要回答墨墨的提问.墨墨会向你发布如下指令: 1. Q L R代表询问你从第L支 ...

  8. P3398 仓鼠找sugar 树上路径相交判断

    \(\color{#0066ff}{题目描述}\) 小仓鼠的和他的基(mei)友(zi)sugar住在地下洞穴中,每个节点的编号为1~n.地下洞穴是一个树形结构.这一天小仓鼠打算从从他的卧室(a)到餐 ...

  9. javascript小菜单—demo

    <!DOCTYPE html><html><head> <title></title></head><body>&l ...

  10. Gym - 101845F 最大流

    The UN finals are here!, the coaches/ex-coaches team is creating a new exciting contest to select wh ...