【模板--完全背包】HDU--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 ?
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.
total value (this number will be less than 231).
5 10
1 2 3 4 5
5 4 3 2 1
#include<cstdio>
#include<algorithm>
using namespace std;
long long dp[+];
int w[],p[];
int main()
{
int t,N,W;
scanf("%d",&t);
while(t--)
{
scanf("%d %d",&N,&W);
for(int i=;i<=N;i++) //
scanf("%d",&p[i]);
for(int i=;i<=N;i++) //
scanf("%d",&w[i]);
for(int i=;i<=W;i++)
dp[i]=;
for(int i=;i<=N;i++) // 这几个地方i开头值注意一样 错了几次..
{
for(int j=W;j>=w[i];j--)
{
dp[j]=max(dp[j],dp[j-w[i]]+p[i]); //核心代码
}
}
printf("%lld\n",dp[W]); } return ;
}
【模板--完全背包】HDU--2602 Bone Collector的更多相关文章
- HDU 2602 Bone Collector 0/1背包
题目链接:pid=2602">HDU 2602 Bone Collector Bone Collector Time Limit: 2000/1000 MS (Java/Others) ...
- 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(经典01背包问题)
题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=2602 Bone Collector Time Limit: 2000/1000 MS (Java/O ...
- HDU 2602 - Bone Collector - [01背包模板题]
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2602 Many years ago , in Teddy’s hometown there was a ...
- 【01背包】HDU 2602 Bone Collector (模板题)
Problem Description Many years ago , in Teddy's hometown there was a man who was called "Bone C ...
- hdu 2602 Bone Collector 背包入门题
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2602 题目分析:0-1背包 注意dp数组的清空, 二维转化为一维后的公式变化 /*Bone Coll ...
- 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 Problem Description Many years ago , in Teddy’s ...
随机推荐
- 数据库外连接及MySQL实现
MySQL查询分为内连接查询和外连接查询,他们的区别在于:内连接查询的两个表示对等关系,根据条件进行匹配:外连接是以某一个表为主,两一个表根据条件进行关联.外连接分为左外连接.右外连接和全外连接.本文 ...
- AngularJS-repeat指令
<body ng-app="myApp"> <div ng-controller="myCtrl"> <ul> <li ...
- 解决发http get请求的时候不成功,出现android.os.NetworkOnMainThreadException的异常
问题描述:在接游戏sdk的时候,由于游戏要求购买的时候是在主线程里面进行的,但是发http请求是不能在主线程里面发,否则就会出现android.os.NetworkOnMainThreadExcept ...
- 文档模型(JSON)使用介绍
一.背景 E.F.Codd在1970年首次提出了数据库系统的关系模型,从此开创了数据库关系方法和关系数据理论的研究,为数据库技术奠定了理论基础,数据库技术也开始蓬勃发展.而随着几大数据库厂商陆续发布的 ...
- 简单粗暴的在vmware虚拟机中固定ip
虚拟机对于很多做测试的或者在学习测试中的人来说是位常客,经常会用到,但是虚拟机重启之后,很多人遇到虚拟机ip变化,很是头痛,我在学习过程中也遇到了这个问题,百度了很多办法,有些办法对于网络知识小白来说 ...
- java实现https请求
package com.lichmama.test; import java.io.IOException; import java.net.URL; import java.security.Key ...
- centos+apache 2.x 开启gzip压缩
最近做了一个网站(PHP+Apache+MySQL),挂在百度云平台上面,基本配置是2G内存+5Mb带宽,每次打开主页都需要2-3s左右的时间,对于一个垂直搜索引擎来说,用户体验肯定会很差. 于是开始 ...
- Hadoop生态系统图解
Hadoop生态架构图 参考文章: Hadoop生态系统介绍 HDFS架构 1.NaneDode:主节点,**存储文件的元数据**如文件名,文件目录结构,文件属性(生成时间,副本数量,文件权限),以及 ...
- MySQL自动化(全量+增量)备份脚本
文章转自:http://www.it-hack.cn/forum.php?mod=viewthread&tid=220&extra=page%3D1 一.MySQL的日常备份方案: 全 ...
- 用户代理字符串(navigator.userAgent)检测方法
最近在看<JavaScript 高级程序设计(第三版)>,发现其中关于用户代理字符串检测技术的一些方法,觉得讲的很详细.用户代理字符串(navigator.userAgent)中包含了大量 ...