0-1背包问题(经典)HDU2602 Bone Collector
Bone Collector
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 36479 Accepted Submission(s): 15052
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 ?

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.
5 10
1 2 3 4 5
5 4 3 2 1
AC code:
#include <iostream>
using namespace std;
int main()
{
int t,n,v,i,j;
int weight[1005],value[1005],record[1005];
cin>>t;
while(t--)
{
memset(record,0,sizeof(record));
cin>>n>>v;
for(i=0; i<n; i++)
cin>>value[i];
for(i=0; i<n; i++)
cin>>weight[i];
for(i=0; i<n; i++)
{
for(j=v;j>=weight[i]; j--)
{
if(record[j-weight[i]]+value[i]>record[j])
record[j] = record[j-weight[i]]+value[i];
}
}
cout<<record[v]<<endl;
} return 0;
}
0-1背包问题(经典)HDU2602 Bone Collector的更多相关文章
- HDU2602 Bone Collector(01背包)
HDU2602 Bone Collector 01背包模板题 #include<stdio.h> #include<math.h> #include<string.h&g ...
- hdu2602 Bone Collector(01背包) 2016-05-24 15:37 57人阅读 评论(0) 收藏
Bone Collector Problem Description Many years ago , in Teddy's hometown there was a man who was call ...
- HDU2602 Bone Collector 【01背包】
Bone Collector Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) T ...
- hdu2602 Bone Collector 01背包
Many years ago , in Teddy’s hometown there was a man who was called “Bone Collector”. This man like ...
- 【模板--完全背包】HDU--2602 Bone Collector
Problem Description Many years ago , in Teddy's hometown there was a man who was called "Bone C ...
- Hdu2602 Bone Collector (01背包)
Problem Description Many years ago , in Teddy’s hometown there was a man who was called “Bone Collec ...
- [原]hdu2602 Bone Collector (01背包)
本文出自:http://blog.csdn.net/svitter 题意:典型到不能再典型的01背包.给了我一遍AC的快感. //=================================== ...
- hdu2602 Bone Collector (01背包)
本文来源于:http://blog.csdn.net/svitter 题意:典型到不能再典型的01背包.给了我一遍AC的快感. //================================== ...
- 解题报告:hdu2602 Bone collector 01背包模板
2017-09-03 15:42:20 writer:pprp 01背包裸题,直接用一维阵列的做法就可以了 /* @theme: 01 背包问题 - 一维阵列 hdu 2602 @writer:ppr ...
随机推荐
- js | JavaScript中数据类型转换总结
转载 在js中,数据类型转换分为显式数据类型转换和隐式数据类型转换. 1, 显式数据类型转换 a:转数字: 1)Number转换: 代码: var a = “123”; a = Number(a); ...
- 批量更新python库
import pip from subprocess import call for dist in pip.get_installed_distributions(): try: call(&quo ...
- IDEA的使用方法(二)(代码提示)
工欲善其事必先利其器: 在eclipse用久了代码提示对自己纯手搓代码还是不太好的,我就算是死,从楼上跳下去,也不会从了IDEA的代码提示的,在手搓了一个hello world之后,我写的是JAVA? ...
- 读键值对封装成Map
描述: 有配置文件address_relation.properties,记录地址关系,有如下数据:ZSSS=ZS%,ZSPD, 封装到Map代码如下: public static void main ...
- scrapy--BeautifulSoup
BeautifulSoup官方文档:https://beautifulsoup.readthedocs.io/zh_CN/latest/#id8 太繁琐的,精简了一些自己用的到的. 1.index.h ...
- [Hdu4825]Xor Sum(01字典树)
Description Zeus 和 Prometheus 做了一个游戏,Prometheus 给 Zeus 一个集合,集合中包含了N个正整数,随后 Prometheus 将向 Zeus 发起M次询问 ...
- 初见spark-02(RDD及其简单算子)
今天,我们来进入spark学习的第二章,发现有很多事都已经开始变化,生活没有简单的朝自己想去的方向,但是还是需要努力呀,不说鸡汤之类的话了, 开始我们今天的spark的旅程 一.RDD是什么 rdd的 ...
- 01,jupyter环境安装
jupyter notebook环境安装 一.什么是Jupyter Notebook? 1. 简介 Jupyter Notebook是基于网页的用于交互计算的应用程序.其可被应用于全过程计算:开发.文 ...
- 1079: [SCOI2008]着色方案
链接 思路 首先是dp,如果直接用每个种颜色的剩余个数做状态的话,复杂度为5^15. 由于c<=5,所以用剩余数量的颜色的种类数做状态:f[a][b][c][d][e][last]表示剩余数量为 ...
- Android webview 加载https网页显示空白
http://www.2cto.com/kf/201110/108836.html 这个网址讲的不错. 设置webview支持https的方法: webView.setWebViewClient(ne ...