【01背包】HDU 2602 Bone Collector (模板题)
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
1
5 10
1 2 3 4 5
5 4 3 2 1
Sample Output
14
Author
Source
#include <iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
using namespace std; long long va[];
int vo[];
long long dp[]; int main()
{
int T,n,v,i,j;
scanf("%d",&T);
while(T--)
{
scanf("%d%d",&n,&v);
for(i=;i<=n;i++)
scanf("%lld",&va[i]);
for(i=;i<=n;i++)
scanf("%d",&vo[i]);
memset(dp,,sizeof(dp));
for(i=;i<=n;i++)
{
for(j=v;j>=vo[i];j--)
{
dp[j]=max(dp[j],dp[j-vo[i]]+va[i]);
}
}
printf("%lld\n",dp[v]);
}
return ;
}
【01背包】HDU 2602 Bone Collector (模板题)的更多相关文章
- 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 ...
- 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 - [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背包裸题)
Bone Collector Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) T ...
- hdu 2602 Bone Collector 背包入门题
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2602 题目分析:0-1背包 注意dp数组的清空, 二维转化为一维后的公式变化 /*Bone Coll ...
- 题解报告:hdu 2602 Bone Collector(01背包)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2602 Problem Description Many years ago , in Teddy’s ...
随机推荐
- WebIM(1)
WebIM系列文章 之前笔者发布的云翔在线软件平台中已经包含了一个功能相对比较齐全的WebIM,这个系列的文章就是介绍如何开发出功能类似的WebIM,在文章开始前,先介绍一下相关的技术: 1.Come ...
- HDInsight-Hadoop现实(两)传感器数据分析
HDInsight-Hadoop现实(两)传感器数据分析 简要 现在,含传感器非常个人和商用设备收集来自物理世界的信息.例如.大多数手机都有 GPS.健身器材可以跟踪的步骤,你去数,恒温控制器可以监视 ...
- 对Extjs中时间的多种处理
1.类型为datetime的json数据处理 (字段类型为datetime) new Date(parseInt(yourTime.substring(6, yourTime.length - 2)) ...
- DbUtility Ex
扩展 DbUtility (1) 2014-05-22 21:48 by Ivony..., 234 阅读, 3 评论, 收藏, 编辑 本文原始路径: https://www.zybuluo.com/ ...
- NUnit单元测试资料汇总
NUnit单元测试资料汇总 从安装到配置 首先到官网http://www.nunit.org/下载如下图的资料,安装NUnit-2.6.1.msi包. 然后挂在VS2010外部工具这个地方来使用,工具 ...
- 用Python实现gmail邮箱服务,实现两个邮箱之间的绑定(上)
一.本程序的起源 当我决定去中科院实习的时候,我给刘奎恩老师发了封邮件.我对此事是非常看重的,因此经常使用浏览器,打开gmail去查看刘老师有没有给我回复.因为gmail的新邮件推送的功能仅限于打开浏 ...
- WebForm页面生命周期WEBFORM_ASPNET控件树的生成和作用
WebForm页面生命周期WEBFORM_ASPNET控件树的生成和作用 摘要 页面类是如何结合后台文件类生成整个页面的HTML的代码和后台输出的代码输出到浏览器中呢?这就牵扯到Asp.net页面生命 ...
- longlistselector 闪烁问题研究
在使用微博的时候,发现微博列表偶尔闪一下.后来自己在写应用的时候也出现了这个问题,不过微博用的是listbox,而我用的是longlistselector.仔细关注了一下,发现闪烁的内容是最后一个it ...
- SQL Server监控清单
SQL Server监控清单 一. 服务器1. 状态监控(1) 服务器是否可访问?(2) 相应的数据库服务是否启用?(3) 操作系统事件日志中的错误或告警(4) 磁盘可用空间 服务器状态监控,不管使用 ...
- NHibernate总结
NHibernate总结 现在的项目中数据访问使用的是NHibernate的一个ORM框架,小弟也是在后期加入项目组,之前对NHibernate就一直没有接触过,所以一直在学习NHibernate,都 ...