POJ3624 - Charm Bracelet(01背包)
来源:互联网 发布:如何下载ppt软件 编辑:程序博客网 时间:2024/05/19 17:06
Charm Bracelet
Time Limit: 1000MS Memory Limit: 65536K
Total Submissions: 36471 Accepted: 15980
Description
Bessie has gone to the mall’s jewelry store and spies a charm bracelet. Of course, she’d like to fill it with the best charms possible from the N (1 ≤ N ≤ 3,402) available charms. Each charm i in the supplied list has a weight Wi (1 ≤ Wi ≤ 400), a ‘desirability’ factor Di (1 ≤ Di ≤ 100), and can be used at most once. Bessie can only support a charm bracelet whose weight is no more than M (1 ≤ M ≤ 12,880).
Given that weight limit as a constraint and a list of the charms with their weights and desirability rating, deduce the maximum possible sum of ratings.
Input
- Line 1: Two space-separated integers: N and M
- Lines 2..N+1: Line i+1 describes charm i with two space-separated integers: Wi and Di
Output
- Line 1: A single integer that is the greatest sum of charm desirabilities that can be achieved given the weight constraints
Sample Input
4 6
1 4
2 6
3 12
2 7
Sample Output
23
#include<cstdio>#include<iostream>#include<string.h>#include<stdlib.h>#include<algorithm>#include<math.h>using namespace std;int dp[12881];int c[3405];int w[3405];int main(){ int n,V; scanf("%d%d",&n,&V); for(int i=1;i<=n;i++) scanf("%d%d",&c[i],&w[i]) ; for(int i=1;i<=n;i++) for(int j=V;j>=c[i];j--) dp[j]=max(dp[j],dp[j-c[i]]+w[i]); cout<<dp[V]<<endl; }
- POJ3624:Charm Bracelet【01背包】
- POJ3624 Charm Bracelet 【01背包】
- 【POJ3624】Charm Bracelet(01背包)
- POJ3624 - Charm Bracelet(01背包)
- poj3624 Charm Bracelet 01背包
- poj3624(Charm Bracelet + 赤裸01背包)
- poj3624 Charm Bracelet DP 01背包问题
- 【POJ3624】Charm Bracelet 01背包裸题
- Charm Bracelet(poj3624)(01背包)
- POJ3624 Charm Bracelet (01背包)
- POJ3624 Charm Bracelet(01背包)
- poj3624 Charm Bracelet(01背包)
- POJ3624 Charm Bracelet 01背包裸题
- POJ3624 Charm Bracelet(01背包问题)
- POJ3624 Charm Bracelet(典型01背包问题)
- (poj3624)Charm Bracelet(01背包)
- POJ3624 Charm Bracelet(01背包问题)
- POJ3624 Charm Bracelet(01背包~~简单DP~~)
- ZooKeeper简介与安装
- Spring 计划任务
- 2016总结与2017的展望
- c语言如何识别无BOM的UTF8文本
- C语言程序设计 翁恺 oj3
- POJ3624 - Charm Bracelet(01背包)
- IOS 地区选择器(swift版本) AreaPickerView_swift
- opencv学习之直方图均衡化
- 六:函数返回值是一个引用
- Javascript的基本数据类型
- Matlab编程与数据类型 -- 分支条件选择语句if/end
- react-native在Anroid真机运行时可能会遇到白屏的情况解决办法
- java学习笔记(高琪版)----抽象类
- 增强学习系列之(二):实现一个简单的增强学习的例子