hud 2602 Bone Collector
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2602
思路:典型的01背包
#include<stdlib.h>
#include<time.h>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <string>
using namespace std; #define N 10005 int val[N],vol[N],dp[N]; int main()
{
int num;
int n,space;
scanf("%d",&num);
while(num--)
{
scanf("%d %d",&n,&space);
for(int i=;i<=n;i++)
scanf("%d",&val[i]);
for(int j=;j<=n;j++)
scanf("%d",&vol[j]); memset(dp,,sizeof(dp));
for(int i=;i<=n;i++)
{
for(int j=space;j-vol[i]>=;j--)
{
dp[j]=max(dp[j],dp[j-vol[i]]+val[i]);
} }
printf("%d\n",dp[space]);
}
return ;
}
hud 2602 Bone Collector的更多相关文章
- 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 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/O ...
- 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背包)
Bone Collector http://acm.hdu.edu.cn/showproblem.php?pid=2602 Problem Description Many years ago , i ...
- 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 Many years ago , in Teddy’s hometown there was a ...
随机推荐
- 关于NGUI与原生2D混用相互遮盖的问题心得
http://www.fzgh.org.cn/zuixindianying/144224.html Native2D自己可以使用Sort Layer来排序,每层又有不同的Order In Layer, ...
- leetcode 63. Unique Paths II
Follow up for "Unique Paths": Now consider if some obstacles are added to the grids. How m ...
- 不安装Oracle客户端使用PLSQL
要连接Oracle往往需要安装上百兆的ORACLE客户端,显得十分麻烦.先就介绍如何通过使用精简客户端,且不需要安装的客户端,配合PLSQL连接oracle数据库. 其实这些操作都很简单,写在这里 ...
- 网页嵌入swf代码
<object class id="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://dow ...
- git分支管理策略
http://www.ruanyifeng.com/blog/2012/07/git.html https://www.digitalocean.com/community/tutorials/how ...
- Smallest Rectangle Enclosing Black Pixels
An image is represented by a binary matrix with 0 as a white pixel and 1 as a black pixel. The black ...
- 【leetcode】First Missing Positive
First Missing Positive Given an unsorted integer array, find the first missing positive integer. For ...
- yum install 安装时报yum doesn't have enough cached data to continue.
yum install 安装时报yum doesn't have enough cached data to continue. 安装epel,yum -y install epel-release后 ...
- java web 学习 --第四天(Java三级考试)
第三天的学习内容:http://www.cnblogs.com/tobecrazy/p/3453041.html jsp内置对象 out out 属性类型:JspWriter 作用域:page 作用: ...
- ABAP 特殊透明表
ADRC 地址 (业务地址服务) 存储所有的有关地址的记录 MSEG 凭证段:物料 存储物料的所有凭证(包括销售.交货.采购等) VBPA-VBELN(销售凭证) VBPA-KUNNR ...