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 ...
随机推荐
- android Activity基类通用方法
public class BaseActivity extends Activity { Resources res; // 通用资源缩写 @Override protected void onCre ...
- Longest Common Substring
Given two strings, find the longest common substring. Return the length of it. Example Given A = &qu ...
- ionic不同view跳转到同一个
ionic不同view跳转到同一个 view并保留历史的路由设计 上代码:state 里面新加一个状态 .state("other", { url: "/other&qu ...
- C++变量对比java变量所占内存
C++ char 1 short int 2 int 4 long int 8 float 4 double 8 long double 8 下面是计算程序: #include<math.h&g ...
- C++中各种容器特点总结
1.vector 内部数据结构:数组,可随机访问元素,在末尾增加或删除元素与元素数目无关,在其 他部分增加或删除元素随着元素数目呈线性变化. 2.deque 数组,按页/块来分配存储,每页/块包含固定 ...
- peewee Model.get的复杂查询
(a | b )&c 官方文档没有具体讲到,又没有太多时间来看源码.经过尝试, (a | b) and c (a or b) and c 都是可以的. 而 (a | b) &c 是不 ...
- Expression Add Operators
Given a string that contains only digits 0-9 and a target value, return all possibilities to add bin ...
- linux mysql查看安装信息
ps -ef|grep mysql root ? :: /bin/sh /usr/bin/mysqld_safe --datadir=/var/lib/mys ...
- java web 学习 --第二天(Java三级考试)
第一天的学习在这http://www.cnblogs.com/tobecrazy/p/3444474.html 2.jsp 基础知识 Jsp页面中的Java脚本主要有3部分:声明(Declaratio ...
- Python 输入输出
语法注释 输入输出 #语法缩进,4个空格 #注释 #冒号:结尾,缩进的预计视为代码块 #大小写敏感 #输出 print 300 print 'hello','world' #输入 a=raw_inpu ...