POJ - 3624

Time Limit: 1000MS   Memory Limit: 65536KB   64bit IO Format: %I64d & %I64u

Submit
Status

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

Source

#include<stdio.h>
#include<string.h>
#include<algorithm>
using namespace std;
int dp[100100];
struct node
{
int w,val;
}edge[100100];
int main()
{
int m,n;
while(scanf("%d%d",&m,&n)!=EOF)
{
memset(dp,0,sizeof(dp));
for(int i=0;i<m;i++)
scanf("%d%d",&edge[i].w,&edge[i].val);
for(int i=0;i<m;i++)
for(int j=n;j>=edge[i].w;j--)
dp[j]=max(dp[j],dp[j-edge[i].w]+edge[i].val);
printf("%d\n",dp[n]);
}
return 0;
}


FAQ | About Virtual Judge | Forum | Discuss | Open Source Project

All Copyright Reserved ©2010-2014 HUST ACM/ICPC TEAM

Anything about the OJ, please ask in the forum, or contact author:Isun

Server Time: 2015-10-14 17:57:36

poj--3624--Charm Bracelet(动态规划 水题)的更多相关文章

  1. POJ.3624 Charm Bracelet(DP 01背包)

    POJ.3624 Charm Bracelet(DP 01背包) 题意分析 裸01背包 代码总览 #include <iostream> #include <cstdio> # ...

  2. POJ 3624 Charm Bracelet(01背包裸题)

    Charm Bracelet Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 38909   Accepted: 16862 ...

  3. POJ 3624 Charm Bracelet(01背包模板题)

    题目链接 Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 52318   Accepted: 21912 Descriptio ...

  4. POJ 3624 Charm Bracelet (01背包)

    题目链接:http://poj.org/problem?id=3624 Bessie has gone to the mall's jewelry store and spies a charm br ...

  5. poj 3624 Charm Bracelet 背包DP

    Charm Bracelet Time Limit: 1 Sec  Memory Limit: 256 MB 题目连接 http://poj.org/problem?id=3624 Descripti ...

  6. POJ 3624 Charm Bracelet(01背包)

    Charm Bracelet Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 34532   Accepted: 15301 ...

  7. poj 3624 Charm Bracelet 01背包问题

    题目链接:poj 3624 这是最基础的背包问题,特点是:每种物品仅有一件,可以选择放或不放.             用子问题定义状态:即F [i, v]表示前i件物品恰放入一个容量为v 的背包可以 ...

  8. POJ 3624 Charm Bracelet(01背包模板)

    Charm Bracelet Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 45191   Accepted: 19318 ...

  9. poj 3624 Charm Bracelet(01背包)

    Charm Bracelet Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 29295   Accepted: 13143 ...

  10. POJ 3624 Charm Bracelet 0-1背包

    传送门:http://poj.org/problem?id=3624 题目大意:XXX去珠宝店,她需要N件首饰,能带的首饰总重量不超过M,要求不超过M的情况下,使首饰的魔力值(D)最大. 0-1背包入 ...

随机推荐

  1. js 判断是否为数字

    if (data.value === "" || data.value == null) { return false; } console.log(!isNaN(data.val ...

  2. node、Mongo项目如何前后端分离提供接口给前端

    node接口编写,vue-cli代理接口方法  通常前端使用的MocK 数据的方法,去模拟假的数据,但是如果有node Mongodb 去写数据的话就不需要在去mock 数据了,具体的方法如下. 首先 ...

  3. java将父类所有的属性COPY到子类中

    public class FatherToChildUtils { /* * 将父类所有的属性COPY到子类中. * 类定义中child一定要extends father: * 而且child和fat ...

  4. springboot:基础学习一 linux下后台启动springboot项目

    我们知道启动springboot的项目有三种方式: 运行主方法启动 使用命令 mvn spring-boot:run”在命令行启动该应用 运行“mvn package”进行打包时,会打包成一个可以直接 ...

  5. day37-1 面向对象高阶

    目录 面向对象高阶 isinstance issubclass 反射(自省) 模块的使用 放在类的使用 call 面向对象高阶 isinstance 判断是否为实例化对象,以后可以用来取代type 和 ...

  6. H3C交换机配置学习随笔

    1.交换机配置VLAN vlan 创建VLAN: <h3c>system-view [h3c]vlan 10 删除ID为10的vlan:undo vlan 10 注:任何型号的交换机,都支 ...

  7. eas之怎么设置单据保存或者提交完不跳到下个新增页面

    this.chkMenuItemSubmitAndAddNew.setSelected(false);

  8. vue,基础整理,夯实基础,为进阶打基础

    把基础部分,再次系统的了解一遍,整理成文档.

  9. grunt入门 出处:http://artwl.cnblogs.com

    grunt-contrib-uglify uglify是一个文件压缩插件,项目地址:https://github.com/gruntjs/grunt-contrib-uglify 本文将以一个DEMO ...

  10. jQuery动态效果

    1.一号店首页 2.淘宝网购物车