hdoj - 2602 Bone Collector
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
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm> using namespace std;
int a[],b[],dp[];
int main()
{
int t,n,v;
scanf("%d",&t);
for(int k=;k<t;k++)
{
memset(dp,,sizeof(dp));
scanf("%d %d",&n,&v);
for(int i = ;i<n;i++)
{
scanf("%d",&a[i]);
}
for(int i = ;i<n;i++)
{
scanf("%d",&b[i]);
} for(int i = ;i<n;i++)
{
for(int j = v;j>=b[i];j--)
{
dp[j] = max(dp[j],dp[j-b[i]]+a[i]); //关键代码 }
}
printf("%d\n",dp[v]);
}
return ;
}
hdoj - 2602 Bone Collector的更多相关文章
- Hdoj 2602.Bone Collector 题解
Problem Description Many years ago , in Teddy's hometown there was a man who was called "Bone C ...
- hdoj 2602 Bone Collector 【01背包】
意甲冠军:给出的数量和袋骨骼的数,然后给每块骨骼的价格值和音量.寻求袋最多可容纳骨骼价格值 难度;这个问题是最基本的01背包称号,不知道的话,推荐看<背包9说话> AC by SWS 主题 ...
- HDOJ(HDU).2602 Bone Collector (DP 01背包)
HDOJ(HDU).2602 Bone Collector (DP 01背包) 题意分析 01背包的裸题 #include <iostream> #include <cstdio&g ...
- hdu 2602 Bone Collector(01背包)模板
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2602 Bone Collector Time Limit: 2000/1000 MS (Java/Ot ...
- HDU 2602 Bone Collector
http://acm.hdu.edu.cn/showproblem.php?pid=2602 Bone Collector Time Limit: 2000/1000 MS (Java/Others) ...
- HDU 2602 Bone Collector 0/1背包
题目链接:pid=2602">HDU 2602 Bone Collector Bone Collector Time Limit: 2000/1000 MS (Java/Others) ...
- HDU 2602 Bone Collector(经典01背包问题)
题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=2602 Bone Collector Time Limit: 2000/1000 MS (Java/O ...
- HDU 2602 Bone Collector (简单01背包)
Bone Collector http://acm.hdu.edu.cn/showproblem.php?pid=2602 Problem Description Many years ago , i ...
- hdu 2602 Bone Collector 背包入门题
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2602 题目分析:0-1背包 注意dp数组的清空, 二维转化为一维后的公式变化 /*Bone Coll ...
随机推荐
- aria config
aria2c --conf-path=aria2.conf mine: max-concurrent-downloads=5 continue=true max-overall-download-li ...
- jQuery判断当前页面是APP内打开还是浏览器打开
一.代码如下: function check_useragent() { var browser = { versions: function() { var u = navigator.userAg ...
- Tensorflow替换静态图中的OP
import tensorflow as tf import collections from tensorflow.core.framework import tensor_shape_pb2 # ...
- 编程风格统一配置EditorConfig
EditorConfig 以纯原生无需任何插件支持 EditorConfig 代码风格配置的编辑器: Visual Studio 2017 开始添加了对 EditorConfig 的原生支持.Visu ...
- idea2019的安装与激活
1.安装及相关资料下载 链接:https://pan.baidu.com/s/1njKjorAvaWftuGCvCQzP3A 提取码:r8h8 2.安装步骤 几乎是傻瓜式的安装,点击下一步即可 注意两 ...
- HDU1213通畅工程-并查集求解
并查集的经典题目. 并查集.经典题目是HDU1232通畅工程. 题目描述: 某省调查城镇交通状况,得到现有城镇道路统计表,表中列出了每条道路直接连通的城镇.省政府"畅通工程"的目标 ...
- Yii2安装任务调度扩展
一.安装扩展 在安装之前添加仓库到composer.json文件中 "repositories": [{"type": "vcs", &qu ...
- golang方法和接口
一. go方法 go方法:在函数的func和函数名间增加一个特殊的接收器类型,接收器可以是结构体类型或非结构体类型.接收器可以在方法内部访问.创建一个接收器类型为Type的methodName方法. ...
- 【转】高性能网络编程4--TCP连接的关闭
TCP连接的关闭有两个方法close和shutdown,这篇文章将尽量精简的说明它们分别做了些什么. 为方便阅读,我们可以带着以下5个问题来阅读本文: 1.当socket被多进程或者多线程共享时,关闭 ...
- MySQL/MariaDB数据库的视图(VIEW)
MySQL/MariaDB数据库的视图(VIEW) 作者:尹正杰 版权声明:原创作品,谢绝转载!否则将追究法律责任. 一.视图概述 1>.什么是视图 视图就是一个虚拟的表,保存有实表的查询结果 ...