poj 3624 01背包 (一维AC)
2012-05-04 16:29
295 查看
#include <iostream> #include <cstdio> #include <string> #include <algorithm> #define Bug cout << "here\n"; using namespace std; const int N = 3450; int bag[12885]; int w , v ; int get_max(int a, int b) { return a > b ? a : b; } int main() { int i, k, n, m; cin >> n >> m; for(i = 1; i <= n; i++) { cin >> w[i] >> v[i]; } memset(bag, 0, sizeof(bag)); for(i = 1; i <= n; i++) { for(k = m; k >= w[i]; k--) { bag[k] = get_max(bag[k], bag[k-w[i]] + v[i]); } /// bag[i][j] = get_min(bag[i-1][j], bag[i-1][j-w[i]]+v[i]); } cout << bag[m] << endl; return 0; }
相关文章推荐
- POJ 3624 (01背包一维求解)
- POJ 3624 Charm Bracelet (01背包)
- poj 3624 Charm Bracelet(简单01背包)
- poj 3624 01背包模板题
- poj 3624 01背包
- 01背包(模板题) 之 poj 3624
- POJ 3624 Charm Bracelet (01背包)
- poj 3624 Charm Bracelet(简单01背包)
- POJ-3624-01背包
- poj 3624(01背包)
- [An AC a day]3624_POJ_ACM
- poj 3624 Charm Bracelet(01背包)
- poj 3624 : Charm Bracelet (01背包)
- poj 3624 dp-01背包
- poj 3624 01背包
- POJ3624 - Charm Bracelet(01背包)
- poj 3624 01背包
- poj3624 01背包
- POJ 3624 Charm Bracelet【01背包】
- POJ 3624 Charm Bracelet【01背包入门题】