hduoj 2602Bone Collector
Bone Collector
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 40598 Accepted Submission(s):
16872
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 ?

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<cstring>
#include<iostream>
#include<stack>
#include<set>
#include<map>
#include<queue>
#include<algorithm>
using namespace std;
#define max(a,b) (a>b?a:b)
int va[],vo[],dp[][];
int main()
{
//freopen("D:\\INPUT.txt","r",stdin);
int t,i,j;
int n,v;
scanf("%d",&t);
while(t--)
{
scanf("%d %d",&n,&v);
for(i=; i<=n; i++)
{
scanf("%d",&va[i]);
}
for(i=; i<=n; i++)
{
scanf("%d",&vo[i]);
}
//dp[i][j] 前i件物品放入j体积的价值的最大值
//dp[i][j]=max(dp[i-1][j],dp[i-1][j-vo[i]]+va[i])
for(i=; i<=n; i++) //i体积
{
for(j=; j<=v; j++)
{
if(j>=vo[i]){
dp[i][j]=max(dp[i-][j],dp[i-][j-vo[i]]+va[i]);
}
else{
dp[i][j]=dp[i-][j];
} //cout<<i<<" "<<j<<" "<<dp[i][j]<<endl;
}
}
printf("%d\n",dp[n][v]);
}
return ;
}
hduoj 2602Bone Collector的更多相关文章
- HDU——2602Bone Collector(01背包)
Bone Collector Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) T ...
- HDU 2602Bone Collector 01背包问题
题意:给出一个t代表有t组数据,然后给出n,n代表有n种石头,v代表旅行者的背包容量,然后给出n种石头的价值和容量大小,求能带走的最大价值 思路:01背包问题,每种石头只有拿与不拿两种状态.(其实我是 ...
- hduoj 1455 && uva 243 E - Sticks
http://acm.hdu.edu.cn/showproblem.php?pid=1455 http://uva.onlinejudge.org/index.php?option=com_onlin ...
- The The Garbage-First (G1) collector since Oracle JDK 7 update 4 and later releases
Refer to http://www.oracle.com/technetwork/tutorials/tutorials-1876574.html for detail. 一些内容复制到这儿 Th ...
- hdu 2602 Bone Collector(01背包)模板
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2602 Bone Collector Time Limit: 2000/1000 MS (Java/Ot ...
- Jmeter plugin jp@gc - PerfMon Metrics Collector
Jmeter由于是开源工具,所以目前有很多插件可以供使用,最简单的方法是先把Plugin Manager安装了 下载地址:https://jmeter-plugins.org/wiki/Plugins ...
- Spring AOP 开发中遇到问题:Caused by: java.lang.IllegalArgumentException: warning no match for this type name: com.xxx.collector.service.impl.XxxServiceImpl [Xlint:invalidAbsoluteTypeName]
在网上找了很多,都不是我想要的,后来发现是我在springaop注解的时候 写错了类名导致的这个问题 @Pointcut("execution(* com.xxx.collector.ser ...
- HDU2639Bone Collector II[01背包第k优值]
Bone Collector II Time Limit: 5000/2000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others ...
- HDOJ 4336 Card Collector
容斥原理+状压 Card Collector Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/O ...
随机推荐
- winform GDI基础(一)
1获取画布 (1)从PaintEventArgs类中获取画布 private void Form1_Paint(object sender, PaintEventArgs e) { Graphics ...
- 读取XML文档存入泛型List<T>集合中
前一篇博文是<泛型List<T>转存为XML文档> http://www.cnblogs.com/insus/p/3277410.html 把一个List<T>集合 ...
- Python中dataframe\ array\ list相互转化
import pandas as pd import numpy as np #创建列表 a1=[1,2,3] #arange函数:指定初始值.终值.步长来创建数组 a2=np.arange(0,1, ...
- 项目管理之码云和git
目录 学习链接 1 码云 1 第一步,注册 2 第二部,登录 2 创建项目 2 git管理 4 如何生成公钥 5 clone项目 5 提交项目 6 1.本地初始化一个项目 6 2.开始第一次上传你的项 ...
- DB2安装步骤
##################################DB2的安装########################### ## 安装前准备 ## 关闭内存地址随机化机制 vi /etc/ ...
- Python学习过程(五)
这里记录下python怎么去和数据库打交道,也就是这么怎么去连接数据库,以及对数据库的操作,我这里用的sqlserver, 好了,首先当然是引入我们的模块包: import pymssql 猜的不错的 ...
- Codeforces Round #520 (Div. 2) B math(素数因子的应用)
题意: 给出一个n ; 有两个操作: 1,mul A , n=n*A : 2,sqrt() , n=sqrt(n) 开更出来必须是整数 : 求出经过这些操作后得出的最小 n , 和 ...
- POJ1185炮兵阵地(状态压缩DP)
POJ飞翔.数据弱 ZQOJ飞翔 数据强 Description 司令部的将军们打算在N×M的网格地图上部署他们的炮兵部队.一个N×M的地图由N行M列组成,地图的每一格可能是山地(用"H&q ...
- 待修改 URAL 1542
#include<bits/stdc++.h> using namespace std; const int maxn = 2e5+2e4+11; const int dep = 666; ...
- mysql 存储引擎介绍
一 存储引擎解释 首先确定一点,存储引擎的概念是MySQL里面才有的,不是所有的关系型数据库都有存储引擎这个概念,后面我们还会说,但是现在要确定这一点. 在讲清楚什么是存储引擎之前,我们先来个比喻, ...