HDU2602(背包)
Bone Collector
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 52296 Accepted Submission(s): 22040
Problem Description
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
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
Sample Input
Sample Output
//2016.9.6
#include <iostream>
#include <cstdio>
#include <cstring> using namespace std; const int N = ;
int dp[N], c[N], w[N]; int main()
{
int T, n, v;
cin>>T;
while(T--)
{
scanf("%d%d", &n, &v);
memset(dp, , sizeof(dp));
for(int i = ; i < n; i++)
scanf("%d", &w[i]);
for(int i = ; i < n; i++)
scanf("%d", &c[i]);
for(int i = ; i < n; i++)
for(int j = v; j >= c[i]; j--)
dp[j] = max(dp[j], dp[j-c[i]]+w[i]);
printf("%d\n", dp[v]);
} return ;
}
HDU2602(背包)的更多相关文章
- hdu-2602&&POJ-3624---01背包裸题
题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=2602 https://vjudge.net/problem/POJ-3624 都是01背包的裸题 这 ...
- HDU2602 Bone Collector(01背包)
HDU2602 Bone Collector 01背包模板题 #include<stdio.h> #include<math.h> #include<string.h&g ...
- [原]hdu2602 Bone Collector (01背包)
本文出自:http://blog.csdn.net/svitter 题意:典型到不能再典型的01背包.给了我一遍AC的快感. //=================================== ...
- 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背包)
本文来源于:http://blog.csdn.net/svitter 题意:典型到不能再典型的01背包.给了我一遍AC的快感. //================================== ...
- hdu2602 Bone Collector 01背包
Many years ago , in Teddy’s hometown there was a man who was called “Bone Collector”. This man like ...
- hdu2602 DP (01背包)
题意:有一个容量 volume 的背包,有一个个给定体积和价值的骨头,问最多能装价值多少. 经典的 01 背包问题不谈,再不会我就要面壁了. 终于有一道题可以说水过了 ……心好累 #include&l ...
- 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背包模板
2017-09-03 15:42:20 writer:pprp 01背包裸题,直接用一维阵列的做法就可以了 /* @theme: 01 背包问题 - 一维阵列 hdu 2602 @writer:ppr ...
随机推荐
- PAT (Advanced Level) 1006. Sign In and Sign Out (25)
简单题. #include<iostream> #include<cstring> #include<cmath> #include<algorithm> ...
- eclipse创建android项目,无法正常预览布局文件
http://jingyan.baidu.com/article/d621e8da0e0e052865913fae.html
- Ibatis自动生成dao sqlmapper文件和domain文件过程
generator自动生成mybatis的xml配置.model.map等信息: 1.下载mybatis-generator-core-1.3.2.jar包. 网址:http://cod ...
- AOJ2249最短路+最小费用
题意:求出某个点到其他点的最短路,并求出在最短路情况下的最小费用 分析:用dijkstra求出最短路并同时更新最小费用即可,注意的是在最短路长度相同时费用取最小即可 #include <iost ...
- iOS推送的众多坑
新来的一家公司,昨天和同事解决推送问题(工程里有集成百度推送和环信即时通讯),信誓旦旦的声称:" app在前台和后台运行时,推送触发的是didReceiveRemoteNotificatio ...
- ZOJ 3927 Programming Ability Test
水题,判断一下加起来是否大于等于80 #include<cstdio> #include<cstring> #include<cmath> #include< ...
- 128階數的Shunt音量控制器
源:128階數的Shunt音量控制器 紅外線遙控 - 256階Shunt音量及控制及音源 選擇器
- IO的五种模型
为了区分IO的五种模型,下面先来看看同步与异步.阻塞与非阻塞的概念差别. 同步:所谓同步,就是在发出一个功能调用时,在没有得到结果之前,该调用就不返回.按照这个定义,其实绝大多数函数都是同步调用(例如 ...
- realvnc的卸载
我安装了realvnc5.3.2后,采用如下方式卸载: (1)用如下命令查询当前安装的realvnc包的全名: rpm -qa realvnc-vnc-server (2) rpm -e 查询到的安装 ...
- AppBarLayout学习笔记
LinearLayout的子类 AppBarLayout要点: 功能:让子View(AppBar)可以选择他们自己的滚动行为. 注意:需要依赖CoordinatorLayout作为父容器,同时也要求一 ...