POJ - 1276 Cash Machine(多重背包)
来源:互联网 发布:网络程序员教程 编辑:程序博客网 时间:2024/05/17 21:54
#include <iostream>#include <cstdlib>#include <cstdio>#include <cstring>#include <string>#include <algorithm>#include <vector>#include <queue>#include <stack>#include <list>#include <set>#include <map>using namespace std;typedef long long LL;typedef unsigned long long LLU;const int maxn=100000+100;int d[maxn], w[maxn], N, n, m;void input_case(){ n=0; while(N--) { int tmp_n, tmp_c; scanf("%d%d", &tmp_n, &tmp_c); int num=1; while(tmp_n>=num) { w[n++]=tmp_c*num; tmp_n-=num; num*=2; } if(tmp_n>0) w[n++]=tmp_c*tmp_n; }}void dp(){ memset(d, 0, sizeof(d)); for(int i=0; i<n; i++) for(int j=m; j>=w[i]; j--) d[j]=max(d[j], d[j-w[i]]+w[i]);}int main(){ while(~scanf("%d%d", &m, &N)) { input_case(); dp(); printf("%d\n", d[m]); } return 0;}
0 0
- POJ 1276 Cash Machine (多重背包)
- POJ 1276 Cash Machine (多重背包)
- 【POJ】1276 Cash Machine(多重背包)
- poj 1276 Cash Machine(多重背包)
- poj 1276 Cash Machine(多重背包)
- POJ - 1276 Cash Machine(多重背包)
- POJ 1276 - Cash Machine(多重背包)
- POJ 1276 Cash Machine(多重背包)
- POJ 1276 Cash Machine(多重背包)
- POJ 1276 Cash Machine (多重背包)
- POJ-1276-Cash Machine(多重背包)
- POJ 1276 Cash Machine(多重背包)
- Cash Machine poj 1276(多重背包)
- poj 1276 Cash Machine (多重背包)
- POJ 1276 Cash Machine (多重背包)
- POJ 1276 Cash Machine(多重背包)
- POJ 1276:Cash Machine (多重背包)
- POJ 1276 Cash Machine(多重背包)
- onInterceptTouchEvent()用于处理事件并改变事件的传递方向。
- E:Could not get lock /var/lib/apt/lists/lock - open (11: Resource temporarily unavailable)
- mysql配置mysql-proxy读写分离
- 不用stl的数组插入排序
- C# 生成指定大小缩略图
- POJ - 1276 Cash Machine(多重背包)
- Linux的伪文件系统
- R0-R37是Arm 的寄存器,就是CPU内部的。而GPIO寄存器都是外设的。换句话说,只要是arm的cpu,包括其他的公司的芯片都会有R0-R37,而GPIO的寄存器就是某个特定的芯片才有。
- uva1424 saleman
- javabean出现找不到属性值的问题解决
- Mina框架研究(3)
- 第24题 Reverse Words in a String
- 将计算机思维故事化——之操作系统典型调度算法
- How to create columns like "bigint" or "longtext" in Rails migrations