POJ.3624 Charm Bracelet(DP 01背包)

题意分析

裸01背包

代码总览

#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#define nmax 13000
#define nnmax 3500
using namespace std;
int dp[nmax];
int w[nnmax],d[nnmax];
int main()
{
int n,m;
while(scanf("%d%d",&n,&m)!= EOF){
memset(dp,0,sizeof(dp));
for(int i =1 ;i<=n;++i) scanf("%d%d",&w[i],&d[i]);
for(int i =1; i<=n; ++i){
for(int j = m; j>=w[i];--j)
dp[j] = max(dp[j],dp[j-w[i]]+d[i]);
}
printf("%d\n",dp[m]);
}
return 0;
}

POJ.3624 Charm Bracelet(DP 01背包)的更多相关文章

  1. 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 ...

  2. POJ 3624 Charm Bracelet(0-1背包模板)

    http://poj.org/problem?id=3624 题意:给出物品的重量和价值,在重量一定的情况下价值尽可能的大. 思路:经典0-1背包.直接套用模板. #include<iostre ...

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

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

  4. poj 3624 Charm Bracelet(01背包)

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

  5. POJ 3624 Charm Bracelet 简单01背包

    题目大意:有n件珠宝,每个珠宝的魅力值为v,重量为w,求在重量不超过m的情况下能达到的最大魅力值. 题目思路:简单的01背包,由于二维数组会超内存所以应该压缩成一维数组. dp[i][j],表示选取i ...

  6. POJ 3624 Charm Bracelet【01背包】

    解题思路:直接套公式就能做的01背包, for(i=1;i<=n;i++) { for(v=w[i];v<=m;v++) f[i,v]=max(f[i,v],f[i-1,v-w[i]]+d ...

  7. poj 3524 Charm Bracelet(01背包)

    Description Bessie has gone to the mall's jewelry store and spies a charm bracelet. Of course, she'd ...

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

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

  9. poj 3624 Charm Bracelet 背包DP

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

随机推荐

  1. Python文件操作大全

    Python 编程文件操作大全   文件打开模式 打开模式 执行操作 'r' 以只读方式打开文件(默认) 'w' 以写入的方式打开文件,会覆盖已存在的文件 'x' 如果文件已经存在,使用此模式打开将引 ...

  2. Spring Cloud(八):配置中心(服务化与高可用)【Finchley 版】

    Spring Cloud(八):配置中心(服务化与高可用)[Finchley 版]  发表于 2018-04-19 |  更新于 2018-04-26 |  本文接之前的<Spring Clou ...

  3. [SHELL]结构化命令之条件语句

    1.if-then语句  #!/bin/bash username="root" if grep $username /etc/passwd then echo "the ...

  4. 正式放弃Edge,重新拥抱Chrome

    从Edge还叫斯巴达的时候我就开始用了,本来对浏览器的要求也没多高,能够打开多个选项卡,稳定,支持最新的规范就好了. 但是Edge真的是越来越让我失望了,卡死问题越来越多,崩溃越来越频繁,我也快奔溃了 ...

  5. 【机器学习】多项式回归python实现

    [机器学习]多项式回归原理介绍 [机器学习]多项式回归python实现 [机器学习]多项式回归sklearn实现 使用python实现多项式回归,没有使用sklearn等机器学习框架,目的是帮助理解算 ...

  6. python3中使用python2中cmp函数出现错误

    在python2中我们经常会使用cmp函数来比较一些东西,但是在python3中,你再来使用这个函数的时候,发现就报错了,提示找不到这个函数,这是为啥呢? 答:新版的python已经舍弃这种用法 而在 ...

  7. [转载]Java集合框架的常见面试题

    http://www.jfox.info/40-ge-java-ji-he-lei-mian-shi-ti-he-da-an 整理自上面链接: Java集合框架为Java编程语言的基础,也是Java面 ...

  8. 五:ResourceManager High Availability RM 高可用

    RM有单点失败的风险,但是可以做HA.  RMs HA通过master/standby这种结构实现,一个master是active的,其它standby是inactive的.可能通过命令行切换主备节点 ...

  9. URAL 1519 Formula 1(插头DP,入门题)

    Description Background Regardless of the fact, that Vologda could not get rights to hold the Winter ...

  10. Linux中常用的关机和重新启动命令

    hutdown.halt.reboot以及init,它们都可以达到关机和重新启动的目的,但是每个命令的内部工作过程是不同的,下面将逐一进行介绍. 一.shutdown shutdown命令用于安全关闭 ...