HDU2602-Bone Collector
描述:
Many years ago , in Teddy’s hometown there was a man who was called “Bone Collector”. This man like to collect varies of bones , such as dog’s , cow’s , also he went to the grave …
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 ?
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.
One integer per line representing the maximum of the total value (this number will be less than 2 31).
代码:
最基本的01背包。
#include<stdio.h>
#include<string.h>
#include<iostream>
#include<stdlib.h>
#include <math.h>
using namespace std;
#define N 1005 int main(){
int T,n,v;
int worth[N],cost[N],dp[N];
scanf("%d",&T);
while( T-- ){
scanf("%d%d",&n,&v);
for( int i=;i<=n;i++ )
scanf("%d",&worth[i]);
for( int i=;i<=n;i++ )
scanf("%d",&cost[i]);
memset(dp,,sizeof(dp));
for( int i=;i<=n;i++ ){
for( int j=v;j>=cost[i];j-- ){
dp[j]=max(dp[j],dp[j-cost[i]]+worth[i]);
}
}
printf("%d\n",dp[v]);
}
system("pause");
return ;
}
HDU2602-Bone Collector的更多相关文章
- HDU2602 Bone Collector(01背包)
HDU2602 Bone Collector 01背包模板题 #include<stdio.h> #include<math.h> #include<string.h&g ...
- HDU2602 Bone Collector 【01背包】
Bone Collector Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) T ...
- 【模板--完全背包】HDU--2602 Bone Collector
Problem Description Many years ago , in Teddy's hometown there was a man who was called "Bone C ...
- hdu2602 Bone Collector 01背包
Many years ago , in Teddy’s hometown there was a man who was called “Bone Collector”. This man like ...
- Hdu2602 Bone Collector (01背包)
Problem Description Many years ago , in Teddy’s hometown there was a man who was called “Bone Collec ...
- hdu2602 Bone Collector(01背包) 2016-05-24 15:37 57人阅读 评论(0) 收藏
Bone Collector Problem Description Many years ago , in Teddy's hometown there was a man who was call ...
- 0-1背包问题(经典)HDU2602 Bone Collector
Bone Collector Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)To ...
- [原]hdu2602 Bone Collector (01背包)
本文出自:http://blog.csdn.net/svitter 题意:典型到不能再典型的01背包.给了我一遍AC的快感. //=================================== ...
- hdu2602 Bone Collector (01背包)
本文来源于:http://blog.csdn.net/svitter 题意:典型到不能再典型的01背包.给了我一遍AC的快感. //================================== ...
- 解题报告:hdu2602 Bone collector 01背包模板
2017-09-03 15:42:20 writer:pprp 01背包裸题,直接用一维阵列的做法就可以了 /* @theme: 01 背包问题 - 一维阵列 hdu 2602 @writer:ppr ...
随机推荐
- objective-c 关键字和概念
@ 看到这个关键字,我们就应该想到,这是Object-C对C语言的扩展,例如@interface XXX. @interface 声明类 @implementation 实现类 @protocol 声 ...
- hdu1285+hdu2467(拓扑排序)
确定比赛名次 Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Total Sub ...
- 2013 多校联合 F Magic Ball Game (hdu 4605)
http://acm.hdu.edu.cn/showproblem.php?pid=4605 Magic Ball Game Time Limit: 10000/5000 MS (Java/Other ...
- Zookeeper 编程
ZooKeeper编程(一) 杂记 ZooKeeper的用途:distributed coordination;maintaining configuration information, namin ...
- 字典 -- 数据结构与算法的javascript描述 第七章
字典 字典是一种以键-值对形式存储数据的数据结构 最基本功能规划 add 添加数据到字典 remove 从字典中移除数据 get 从字典中取出数据 count 统计字典数据量 find 查找数据在字典 ...
- Deep Learning(深度学习)学习笔记整理系列之(二)
Deep Learning(深度学习)学习笔记整理系列 zouxy09@qq.com http://blog.csdn.net/zouxy09 作者:Zouxy version 1.0 2013-04 ...
- FlashFXP使用教程
点FlashFXP菜单栏“站点-站点管理”打开站点管理器.然后点新建站点,输入站点名称(随意),确定. 编辑站点管理器里新建的站点的相关信息,包括站点名称.地址.用户名称.密码等.编辑完成,点应用 ...
- 向上取整Ceil,向下取整Floor,四舍五入Round
几个数值函数的功能实现: (1)int Ceil(float f) int Ceil(float f) { int integer = (int)f; if (f > (float)intege ...
- C++函数传值调用
C++的函数的参数调用是传值方式. 想要改变传值调用,有引用和指针两种方式.其中,引用的实现机理也是通过一个指针,但是具体和指针传值的方式又不一样.具体见:C++中的指针与引用 对于指针传值,其实实际 ...
- <a>元素生成多个<a>的问题,元素标签结尾影响
告诉我不是真的吧,<a/>和<a></a>真的有区别...