C - Bone Collector(背包问题)(01背包)
C - 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 ?
- 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 2 31).
- Sample Input
-
1 5 10 1 2 3 4 5 5 4 3 2 1
- Sample Output
-
14
嗯一道简单的01背包问题
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<iostream>
using namespace std;
#define maxn 1005
int over[maxn];
int volume[maxn];
int value[maxn];
int main()
{int t;scanf("%d",&t);while(t--){int n,m,i,j;scanf("%d%d",&n,&m);memset(value,0,sizeof(value));memset(volume,0,sizeof(volume));memset(over,0,sizeof(over));for( i=1;i<=n;i++)scanf("%d",&value[i]);for( i=1;i<=n;i++)scanf("%d",&volume[i]);for(i=1;i<=n;i++){for(j=m;j>=volume[i];j--){over[j]=max(over[j],over[j-volume[i]]+value[i]);}}printf("%d\n",over[m]);}
return 0;
}
C - Bone Collector(背包问题)(01背包)相关推荐
- hdu 2602 Bone Collector(01背包)模板
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2602 Bone Collector Time Limit: 2000/1000 MS (Java/Ot ...
- HDU Problem 2062 Bone Collector【01背包】
Bone Collector Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) T ...
- HD 2602 Bone Collector (0-1背包)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2602 Problem Description Many years ago , in Teddy's ...
- HDU 2602 Bone Collector DP(01背包)
Bone Collector Time Limit:1000MS Memory Limit:32768KB 64bit IO Format:%I64d & %I64u Desc ...
- hdu 2602 Bone Collector(01背包)
题意:给出包裹的大小v,然后给出n块骨头的价值value和体积volume,求出一路下来包裹可以携带骨头最大价值 思路:01背包 1.二维数组(不常用 #include<iostream> ...
- Bone Collector【01背包】
F - Bone Collector HDU - 2602 Many years ago , in Teddy's hometown there was a man who was called &q ...
- B - Bone Collector (01背包)
题目: 涂奥最近迷上了吃鸡,房间有n个配件,每个配件有c(c<=1e3)的重量和v(v<=1e3)的价值,哇,涂奥捡了一个2级包,容量为s,所以涂奥最多当多肥的快递员呢? Input 输入 ...
- HDU2602Bone Collector 简单0-1背包
HDU2602Bone Collector 简单0-1背包 Bone Collector Time Limit: 2000/1000 MS (Java/Others) Memory Limit: ...
- 背包问题——01背包
背包问题--01背包 01背包作为动态规划(dynamic programing)中最基础的问题,需要我们彻底理解其中的原理,为以后解决更难的动态规划问题打下良好的基础. 这里拟定一个01背包问题: ...
- 动态规划之背包问题——01背包
算法相关数据结构总结: 序号 数据结构 文章 1 动态规划 动态规划之背包问题--01背包 动态规划之背包问题--完全背包 动态规划之打家劫舍系列问题 动态规划之股票买卖系列问题 动态规划之子序列问题 ...
最新文章
- pandas.series的数据定位为什么用两个左中括号[[
- Winform中设置ZedGraph鼠标滚轮缩放的灵敏度以及设置滚轮缩放的方式(鼠标焦点为中心还是图形中心点)
- 快速读书的方法(对于理工科的可能适用)
- web安全之CSRF
- python斐波那契前20递归_算法python实现经典递归问题(汉诺塔, 斐波那契数列,阶乘)...
- 2017.9.8 字符串 失败总结
- 树莓派安装摄像头、耳机、话筒
- javascript设计模式 ---序
- HCIE Security 防火墙虚拟系统 备考笔记(幕布)
- vscode解决方案 关闭源代码管理
- 当前常见游戏服务器引擎
- react17.x+MDUI实现todo小案例,react动态添加与删除元素属性
- SQL注入(持续更新中)
- BTA分论坛现场直击|区块链+时下新科技,你了解多少?
- 锆石科技的FPGA教学视频
- sql date_format用法
- 资本运作模式(融资与投资) - 运营管理文章
- 速学TypeScript-精简划重点手册-上册
- vue-cli3 跑项目时 ‘98%’ after emitting CopyPlugin
- 抖音seo矩阵系统,抖音矩阵系统源码怎么搭建?