POJ3624 01背包
来源:互联网 发布:hessian矩阵 编辑:程序博客网 时间:2024/06/05 06:23
这题太裸
就是从后向前一个一个填,一种一种的填
拿出来他的重量,加进去他的价值
#include<iostream>#include<cmath>#include<queue>#include<algorithm>#include<cstdlib>using namespace std;int dp[12881];int zhi[3403];int zhong[3403];int main(){ int n, m; cin >> n >> m; for (int a = 1;a <= n;a++)cin >> zhong[a] >> zhi[a]; int sum = 0; for (int a = 1;a <= n;a++) { for (int b = m;b >= 0;b--) { if (b - zhong[a] >= 0) { dp[b] = max(dp[b], dp[b - zhong[a]] + zhi[a]); sum = max(sum, dp[b]); } } } cout << sum << endl; return 0;}
0 0
- poj3624--01背包
- POJ3624 01背包
- poj3624 dp 01背包
- 1poj3624(01背包)
- poj3624--01背包
- poj3624(01背包)
- 01背包-poj3624
- poj3624 01背包
- POJ3624(01背包问题)
- 01背包poj3624
- poj3624 01背包
- POJ3624 01背包问题
- POJ3624 01背包
- POJ3624--01背包
- poj3624 01背包
- poj3624 01背包
- POJ3624 01背包
- POJ3624——01背包
- javascript高级之操作符、作用域
- 答案1
- Android版本和API Level的对应关系
- 安装Composer与laravel安装
- 使用hexo搭建个人博客
- POJ3624 01背包
- 跨域资源共享 CORS 详解
- POJ2632——Crashing Robots
- 关于vertical-align的一些心得
- HashMap、HashTable
- java 线程干扰, 内存一致性错误(happens-before)
- super关键字
- python爬虫之hearder验证缺失
- 程序人生之二:十年 IT 生涯感情祭