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 ...
随机推荐
- 在Linux系统中创建SSH服务器别名
如果你经常通过 SSH 访问许多不同的远程系统,这个技巧将为你节省一些时间.你可以通过 SSH 为频繁访问的系统创建 SSH 别名,这样你就不必记住所有不同的用户名.主机名.SSH 端口号和 IP 地 ...
- 【转载】C#中List集合使用IndexOf判断元素第一次出现的索引位置
在C#的List集合操作中,有时候需要判断元素对象在List集合中第一次出现的索引位置信息,此时需要使用到List集合的IndexOf方法来判断,如果元素存在List集合中,则IndexOf方法返回所 ...
- vue从零开始(三)指令
v-bind的使用 <!-- 绑定一个属性 --> <img v-bind:src="imageSrc"> <!-- 动态特性名 (2.6.0+) - ...
- 如何免费试用SAP的Fiori应用
什么是SAP Fiori?SAP Fiori不是SAP发布的某款产品,而是SAP新一代UI设计风格和用户体验的代号. Fiori是一个意大利语中的单词,意思是"花": 不得不说SA ...
- Ubuntu 系统装机指南
1.vim设置 2.git配置 3.系统性能监视器:Ubuntu安装系统监视器 4.编译环境安装:sudo apt-get install build-essential
- 关于git报 warning: LF will be replaced by CRLF in README.md.的警告的解决办法
在使用git把代码上传至仓库时,会有下面这种警告: 虽然说是警告,但是看着真的很碍眼啊,特别是有强迫症的人就更难受了. 输入这一行命令就可以完美解决了 git config core.autocrlf ...
- 【RocketMQ异常】Caused by: com.aliyun.openservices.shade.com.alibaba.rocketmq.client.exception.MQClientException: No route info of this topic, message-service-topic-testf
一.异常信息 -- ::-thread-] ERROR c.x.x.r.service.producer.ali.AliMQProducerProcess.sendMessageFromQueue(A ...
- PostgreSQL日志分析工具
PostgreSQL日志分析工具 postgresqllinux PostgreSQL日志审计可以配合 pgbench.jmeter...测试工具制定测试计划测试性能,由于日志审计比较影响性能,在不需 ...
- Environment类在代码中的使用
string environmentVariable = Environment.GetEnvironmentVariable("TrustMerchantIniFile"); 可 ...
- python dijkstra 最短路算法示意代码
def dijkstra(graph, from_node, to_node): q, seen = [(0, from_node, [])], set() while q: cost, node, ...