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 ...
随机推荐
- 二、Cocos2dx中Android部分的c++和java实现相互调用(高级篇)
本文由qinning199原创,转载请注明:http://www.cocos2dx.net/?p=97 本文目的 要完成在cocos2dx的场景上一个点击事件,传递一个消息到java层,下面让我们看看 ...
- JQ工具函数运用
1.把对象转换为字符串 <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <he ...
- iWeb峰会见闻
8.16去参加了iWeb峰会,一大早8点过10分就到了,发现外面已经排起了长队(说明影响力越来越大,关注的人越来越多了.) 此次大会参与的企业也越来越多,当然是有目的而来~ 上午 google商业合作 ...
- copyleft 与 copyright
直到今天才知道Copyleft这个名词(orz...) 我们经常能见到的是 Copyright(著作权),这个对版权的保护,保证作者权益. 它的对立面就是Copyleft,它允许用户自由修改 使用作品 ...
- 自己定义flash的宽和高
前段时间做个项目,是个网页的聊天界面,聊天的内容使用flash制作,我需要将flash的swf插件放到页面上,然后获取聊天内容, 1.将文件在页面上显现出来: 如图,正中间使用后台制作出来的swf文件 ...
- Android数据的四种存储方式SharedPreferences、SQLite、Content Provider和File (三) —— SharePreferences
除了SQLite数据库外,SharedPreferences也是一种轻型的数据存储方式,它的本质是基于XML文件存储key-value键值对数据,通常用来存储一些简单的配置信息.其存储位置在/data ...
- 2014.9.16HTML表单CSS
(一)表格 合并单元格(少用) (合并列) 1.先选中要合并的2个或多个单元格,然后点击以下图标 代码:<td colspan="2"> </td> 2.设 ...
- pl sql项目演练--B2C商城项目
项目学习视频下载地址:点击下载 1.注册会员及找回密码模块 }该模块主要功能有注册会员和找回密码 }注册会员:所需信息主要有:登录号.密码.真实姓名.性别.密码问题.密码答案.Email.地址.电 ...
- iOS中关于动态Tableview中的cell数据传输的多线程问题解决之拙见
iOS中关于动态Tableview中的cell数据传输的多线程问题解决之拙见 (2015-12-05 12:48:20)[编辑][删除] 转载▼ 首先我们先明确一下问题: 1.因为UI是在主线 ...
- STL模板_multimap_智能指针作为键值
map的键值的类型 -可以是自定的类型(对象.函数指针.智能指针....) -但是有副作用-当自己定义的类型键值无法用系统自己提供的 < 或者 > 进行排序的时候,会出现各种问题 -所以需 ...