Bone Collector

Time Limit: 1000ms
Memory Limit: 32768KB
 
This problem will be judged on HDU. Original ID: 2602
64-bit integer IO format: %I64d      Java class name: Main
 
 
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
 

Source

 
 
解题:0-1背包。。。
 
 #include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <vector>
#include <climits>
#include <ctype.h>
#include <cmath>
#include <algorithm>
#define LL long long
using namespace std;
int v[],w[],dp[];
int main(){
int kase,i,j,n,m;
scanf("%d",&kase);
while(kase--){
memset(dp,,sizeof(dp));
scanf("%d %d",&n,&m);
for(i = ; i <= n; i++)
scanf("%d",v+i);
for(i = ; i <= n; i++)
scanf("%d",w+i);
for(i = ; i <= n; i++){
for(j = m; j >= w[i]; j--){
dp[j] = max(dp[j],dp[j-w[i]]+v[i]);
}
}
printf("%d\n",dp[m]);
}
return ;
}

BNUOJ 6727 Bone Collector的更多相关文章

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

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

  2. HDU 2602 Bone Collector WA谁来帮忙找找错

    Problem Description Many years ago , in Teddy’s hometown there was a man who was called “Bone Collec ...

  3. Bone Collector(01背包)

    题目链接:http://acm.hust.edu.cn/vjudge/contest/view.action?cid=87125#problem/N 题目: Description Many year ...

  4. HDU 3639 Bone Collector II(01背包第K优解)

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

  5. Bone Collector II

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

  6. HDU 2602 Bone Collector (简单01背包)

    Bone Collector http://acm.hdu.edu.cn/showproblem.php?pid=2602 Problem Description Many years ago , i ...

  7. hdu 2602 Bone Collector 背包入门题

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2602 题目分析:0-1背包  注意dp数组的清空, 二维转化为一维后的公式变化 /*Bone Coll ...

  8. hdu 2639 Bone Collector II

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

  9. 杭电 2602 Bone Collector

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

随机推荐

  1. 对shell的简单认识

    shell是一个命令解释器: shell分为交互式shell和非交互式shell: 交互式shell就是命令行一问一答:非交互式shell是像shell文本那样,一次解析文本, 并未在命令行给我们作出 ...

  2. localStorage 和 sessionStorage的区别

    存储对象: 在主流浏览器中,添加了html5  Web Storage API 的接口,storage是一个存储对象,它包括会话存储(session storage)或本地存储(local stora ...

  3. 【Linux】使用Cockpit进行主机管理

    Cockpit 进行主机监控 官网文档: https://cockpit-project.org/running.html 版本信息 针对Red Hat [root@master ~]# cat /e ...

  4. IT兄弟连 JavaWeb教程 Servlet定义以及环境配置 BS程序和CS程序

    随着网络技术的不断发展,单机的软件程序已难以满足网络计算机的需求.为此,各种各样的网络程序开发体系结构应运而生.其中,运用最多的网络应用程序开发体系结构可以分为两种,一种是基于客户端/服务器的C/S结 ...

  5. 面向对象super内置函数(转)

    super函数用来解决钻石继承. 一.python的继承以及调用父类成员 父类: class Base(object): def __init__(self): print("base in ...

  6. vue+webpack+VS Code入门简单的项目配置

    为了方便,这边的编译器选择的是VS Code (Visual Studio Code); 打开VS Code,选择好自己的工作空间,然后新建一个文件夹作为我们项目的文件夹,然后,show time: ...

  7. Android项目中包名的修改

    通常修改包名时会造成R文件错误,并且有时带有原因不明的Manifest文件中多处文本混乱. 所以,将目前认为最为简洁方便的修改包名流程记录如下: 假设我们目前的包名为com.pepper.util,我 ...

  8. jquery 不支持$.browser

    if (!$.browser) { $.browser = { mozilla : /firefox/.test(navigator.userAgent.toLowerCase()), webkit ...

  9. 解决Errno::ENOENT: No Such File or Directory - Jekyll ~ Octopress and El Capitan

    参考http://schalkneethling.github.io/blog/2015/10/16/errno-enoent-no-such-file-or-directory-jekyll-oct ...

  10. CDN加速静态文件服务器的访问

    1.用于加速用户下载资源的速度. 简单来说,CDN相当于一个中间代理,原来我们需要请求某个网址比如www.baidu.com,请求会直接发送至百度的服务器上,假如请求者在新疆,但百度的服务器在北京,这 ...