HDU2602(背包)
Bone Collector
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 52296 Accepted Submission(s): 22040
Problem Description
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 ?
Input
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.
Output
Sample Input
Sample Output
1 //2016.9.6 2 #include <iostream> 3 #include <cstdio> 4 #include <cstring> 5 6 using namespace std; 7 8 const int N = 1005; 9 int dp[N], c[N], w[N]; 10 11 int main() 12 { 13 int T, n, v; 14 cin>>T; 15 while(T--) 16 { 17 scanf("%d%d", &n, &v); 18 memset(dp, 0, sizeof(dp)); 19 for(int i = 0; i < n; i++) 20 scanf("%d", &w[i]); 21 for(int i = 0; i < n; i++) 22 scanf("%d", &c[i]); 23 for(int i = 0; i < n; i++) 24 for(int j = v; j >= c[i]; j--) 25 dp[j] = max(dp[j], dp[j-c[i]]+w[i]); 26 printf("%d\n", dp[v]); 27 } 28 29 return 0; 30 }
转载于:https://www.cnblogs.com/Penn000/p/5849076.html
HDU2602(背包)相关推荐
- HDU2602 (0-1背包)
Bone Collector Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) T ...
- 背包——01背包Bone Collector(hdu2602)
首先说明一下01背包 有一个容量为V的背包,另外有N个物品,每个物品Ni都有其对应的体积Vi和价值Pi 求如何取舍装进背包中使得背包里的总价值P达到最大值 题目看似很像贪心问题,把我们不妨先以贪心的思 ...
- HDU2602 Bone Collector【0/1背包+DP】
Bone Collector Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) T ...
- hdu2602 骨头收集者 01背包 模板题
Bone Collector Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) T ...
- HDU 2639(01背包求第K大值)
题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=2639 Bone Collector II Time Limit: 5000/2000 MS (Jav ...
- 01背包经典例题详解
转载自点击打开链接 首先01背包题目的雏形是 有N件物品和一个容量为V的背包.第i件物品的费用是c[i],价值是w[i].求解将哪些物品装入背包可使价值总和最大. 从这个题目中可以看出,01背包的特点 ...
- 【背包专题】01背包
暑假集训开始了,按照队里的分配,我是弄DP的,嘛,于是我又一次的开始了从01背包开始学习,昨天将杭电的几道01背包重新做了一遍,下面讲讲我自己对于01背包的理解. 首先01背包题目的雏形是 有N件物品 ...
- 暑假N天乐 —— 01背包及变形
暑假集训的第一天 第二天了. 决定还是先把基础巩固一下好了,万一后面训练赛出事故更尴尬. 所以今天的主题是 -- 01背包及变形 动态规划概念 动态规划(Dynamic programming,DP) ...
- HDU 1248 寒冰王座(全然背包:入门题)
HDU 1248 寒冰王座(全然背包:入门题) http://acm.hdu.edu.cn/showproblem.php?pid=1248 题意: 不死族的巫妖王发工资拉,死亡骑士拿到一张N元的钞票 ...
最新文章
- SAP云平台cf push命令报错误码44的解决方法
- openfire 插件开发例子
- [转]JavaScript面向对象的特性
- amd显卡风扇调节_为什么NVIDIA和AMD公版显卡纷纷摒弃涡轮散热器而采用多风扇散热设计?...
- python数值比较器_python笔记16(数据处理笔记1)
- Angular Taskmgr 登录
- PHP的日期时间函数date()
- YTU OJ-1329: 手机尾号评分
- python 换页符_python分页字符串
- 【渝粤教育】电大中专跨境电子商务理论与实务 (12)作业 题库
- 水文预报 求各个年份的纳什效率系数
- FPGA图像处理12_常用算法_饱和度调节
- 实现简单的三D立方体自动旋转
- 大学生考系统集成项目管理工程师有什么用?
- CHAP6:通过可视化艺术共享数据
- 地推脑30秒速装华为移动应用引擎,电脑也能玩安卓
- 痞子衡嵌入式:MCUBootUtility v4.0发布,开始支持MCX啦
- Android布局动画之animateLayoutChanges与LayoutTransition
- python海康威视网络摄像头_OpenCV:非海康威视大华宇视(其他)网络摄像头IPC 二次开发(Python)获取视频图像...
- Docker学习笔记六:Docker搭建企业级私有仓库
热门文章
- Android中ContentProvider组件详解
- Java 启动参数大全
- Python中dict详解
- linux下的图形界面扫雷游戏(Gtk+2.0)
- 蓝桥杯 ALGO-123 算法训练 A+B problem
- PAT 乙级 1019. 数字黑洞 (20) Java版
- LeetCode 152. Maximum Product Subarray
- 出现次数最多的整数-蓝桥杯算法训练
- Oracle和al,ORACLEAL TERTABLE
- php无法连接远程服务器,php-无法在远程服务器上包含文件