POJ 3624 Charm Bracelet(0-1背包模板)
http://poj.org/problem?id=3624
题意:给出物品的重量和价值,在重量一定的情况下价值尽可能的大。
思路:经典0-1背包。直接套用模板。
#include<iostream>
#include<algorithm>
using namespace std; const int maxn = ; int n, m;
int dp[maxn]; int W[], D[]; int main()
{
//freopen("D:\\txt.txt", "r", stdin);
while (cin >> n >> m && n && m)
{
memset(dp, , sizeof(dp));
for (int i = ; i <= n; i++)
cin >> W[i] >> D[i]; for (int i = ; i <= n; i++)
{
for (int j = m; j >= W[i]; j--)
{
dp[j] = max(dp[j], dp[j - W[i]] + D[i]);
}
}
cout << dp[m] << endl;
}
return ;
}
POJ 3624 Charm Bracelet(0-1背包模板)的更多相关文章
- POJ 3624 Charm Bracelet(01背包模板)
Charm Bracelet Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 45191 Accepted: 19318 ...
- POJ.3624 Charm Bracelet(DP 01背包)
POJ.3624 Charm Bracelet(DP 01背包) 题意分析 裸01背包 代码总览 #include <iostream> #include <cstdio> # ...
- 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 ...
- poj 3624 Charm Bracelet(01背包)
Charm Bracelet Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 29295 Accepted: 13143 ...
- 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 ...
- POJ 3624 Charm Bracelet 简单01背包
题目大意:有n件珠宝,每个珠宝的魅力值为v,重量为w,求在重量不超过m的情况下能达到的最大魅力值. 题目思路:简单的01背包,由于二维数组会超内存所以应该压缩成一维数组. dp[i][j],表示选取i ...
- POJ 3624 Charm Bracelet(01背包模板题)
题目链接 Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 52318 Accepted: 21912 Descriptio ...
- poj 3624 Charm Bracelet 背包DP
Charm Bracelet Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://poj.org/problem?id=3624 Descripti ...
- POJ 3624 Charm Bracelet(01背包裸题)
Charm Bracelet Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 38909 Accepted: 16862 ...
随机推荐
- 004-spring cloud gateway-网关请求处理过程
一.网关请求处理过程 客户端向Spring Cloud Gateway发出请求.如果网关处理程序映射确定请求与路由匹配,则将其发送到网关Web处理程序.此处理程序运行通过特定于请求的过滤器链发送请求. ...
- Git:pull --rebase 和 merge --no-ff
首先是吐嘈 如果你正在 code review,看到上图(下文将称之为:提交线图)之后,特别是像我这样有某种洁癖的人,是否感觉特别难受?如果是的话,请看下文吧 :) 为什么 Git 作为分布式版本控制 ...
- 【Rewrite重定向】Nginx使用rewrite重新定向
使用nginx做重新定向. nginx参考网址:http://blog.sina.com.cn/s/blog_97688f8e0100zws5.html 语法规则: location [=|~|~*| ...
- linux字符处理命令 sort(部分转载)
[root@LocalWeb01 ~]# sort /etc/passwd |less (升序 ) [root@LocalWeb01 ~]# sort -r /etc/passwd |less ( ...
- UVM中的driver组件
一般UVM环境中的Driver组件,派生自uvm_driver. uvm_dirver派生自uvm_component. class uvm_driver #(type REQ = uvm_sequ ...
- python webdriver 从无到有搭建数据驱动自动化测试框架的步骤和总结
一步一步搭建数据驱动测试框架的过程和总结 跟吴老学了搭建自动化数据驱动的框架后,我在自己练习的时候,尝试从简单的程序进行一点一点的扩展和优化,到实现这个数据驱动的框架. 先说一下搭建自动化测试框架的目 ...
- keepalived+MySQL高可用集群
基于keepalived搭建MySQL的高可用集群 MySQL的高可用方案一般有如下几种: keepalived+双主,MHA,MMM,Heartbeat+DRBD,PXC,Galera Clus ...
- linux查看是否能访问外网及拥有的公网IP
linux查看是否能访问外网及拥有的公网IP linux查看是否能访问外网及拥有的公网IP: 1,测访问外网能力:curl -l http://www.baidu.com 2,测访问外网能力:wget ...
- Linux 系统版本信息
1.# uname -a (Linux查看版本当前操作系统内核信息) 2.# cat /proc/version (Linux查看当前操作系统版本信息) 3.# cat /etc/issue 或 ...
- PHP-Iterator迭代器(遍历)接口详讲
echo "<meta http-equiv='Content-Type' content='text/html; charset=utf-8' /> "; class ...