hdu 2602 - Bone Collector(01背包)解题报告
Bone Collector
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 39532 Accepted Submission(s): 16385
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.
1
5 10
1 2 3 4 5
5 4 3 2 1
14
题解:
裸的01背包,经典例题。
參考代码:
#include<stdio.h>
#define M 1111
#include<string.h>
int max(int a,int b)
{
return a>b?a:b;
}
int main()
{
int t,a[M],b[M],dp[M];
scanf("%d",&t);
while(t--)
{
int n,v;
memset(dp,0,sizeof(dp));
scanf("%d%d",&n,&v);
for(int i=0;i<n;i++)
scanf("%d",&b[i]);
for(int i=0;i<n;i++)
scanf("%d",&a[i]);
for(int i=0;i<n;i++)
{
for(int j=v;j>=a[i];j--)
{
dp[j]=max(dp[j],dp[j-a[i]]+b[i]);
}
}
printf("%d\n",dp[v]);
}
return 0;
}
hdu 2602 - Bone Collector(01背包)解题报告的更多相关文章
- HDU 2602 Bone Collector(01背包裸题)
Bone Collector Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) T ...
- HDU 2602 - Bone Collector - [01背包模板题]
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2602 Many years ago , in Teddy’s hometown there was a ...
- HDU 2602 Bone Collector --01背包
这种01背包的裸题,本来是不想写解题报告的.但是鉴于还没写过背包的解题报告.于是来一发. 这个真的是裸的01背包. 代码: #include <iostream> #include < ...
- HDU 2602 Bone Collector (01背包DP)
题意:给定一个体积,和一些物品的价值和体积,问你最大的价值. 析:最基础的01背包,dp[i] 表示体积 i 时最大价值. 代码如下: #pragma comment(linker, "/S ...
- [HDU 2602]Bone Collector ( 0-1背包水题 )
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2602 水题啊水题 还给我WA了好多次 因为我在j<w[i]的时候状态没有下传.. #includ ...
- HDU 2602 Bone Collector (01背包问题)
原题代号:HDU 2602 原题链接:http://acm.hdu.edu.cn/showproblem.php?pid=2602 原题描述: Problem Description Many yea ...
- HDOJ(HDU).2602 Bone Collector (DP 01背包)
HDOJ(HDU).2602 Bone Collector (DP 01背包) 题意分析 01背包的裸题 #include <iostream> #include <cstdio&g ...
- 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/Ot ...
- HDU 2602 Bone Collector(经典01背包问题)
题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=2602 Bone Collector Time Limit: 2000/1000 MS (Java/O ...
随机推荐
- UVA11806 Cheerleaders (容斥)
题目链接 Solution 可以考虑到总方案即为 \(C_{nm}^k\) . 考虑到要求的是边缘都必须至少有 \(1\) ,所以考虑不合法的. 第一行和最后一行没有的方案即为 \(C_{(n-1)m ...
- 80人环游世界(bzoj 2055)
Description 想必大家都看过成龙大哥的<80天环游世界>,里面的紧张刺激的打斗场面一定给你留下了深刻的印象.现在就有这么 一个80人的团伙,也想来一次环游世界. ...
- [AGC004D] Teleporter(贪心+)
Description 维尼管辖的领土很大,我们可以抽象为n个城市,其中1号点为首都.这n个城市之有n条单向电缆,一条信息经过一条电缆进行传输所需时间会+1s,然而维尼并不能忍受时间白白被续,他要求从 ...
- [LeetCode] Sum Root to Leaf Numbers dfs,深度搜索
Given a binary tree containing digits from 0-9 only, each root-to-leaf path could represent a number ...
- hdu 3980 Paint Chain 组合游戏 SG函数
题目链接 题意 有一个\(n\)个珠子的环,两人轮流给环上的珠子涂色.规定每次涂色必须涂连续的\(m\)颗珠子,无法继续操作的人输.问先手能否赢. 思路 参考 转化 第一个人取完之后就变成了一条链,现 ...
- 《Linux内核Makefile分析》之 auto.conf, auto.conf.cmd, autoconf.h【转】
转自:http://blog.sina.com.cn/s/blog_87c063060101l25y.html 转载:http://blog.csdn.net/lcw_202/article/deta ...
- Linux Shell 文本处理工具集锦【转】
转自:http://www.cnblogs.com/me115/p/3427319.html 内容目录: find 文件查找 grep 文本搜索 xargs 命令行参数转换 sort 排序 uniq ...
- [Python Cookbook] Numpy Array Slicing and Indexing
1-D Array Indexing Use bracket notation [ ] to get the value at a specific index. Remember that inde ...
- SQL Server的WAITFOR DELAY注入
SQL Server的WAITFOR DELAY注入 WAITFOR是SQL Server中Transact-SQL提供的一个流程控制语句.它的作用就是等待特定时间,然后继续执行后续的语句.它包含 ...
- Spoj MKTHNUM - K-th Number
题目描述 English Vietnamese You are working for Macrohard company in data structures department. After f ...