AcWing 9. 分组背包问题
标签:背包问题 int clu pac bsp cin style div 分组
#include
#include
using namespace std;
const int N = 110;
int n, m;
int v[N][N], w[N][N], s[N];
int f[N];
int main() {
cin >> n >> m;
for (int i = 1; i ) {
cin >> s[i];
for (int j = 0; j )
cin >> v[i][j] >> w[i][j];
}
for (int i = 1; i )
for (int j = m; j >= 0; j -- )
for (int k = 0; k )
if (v[i][k] j)
f[j] = max(f[j], f[j - v[i][k]] + w[i][k]);
cout endl;
return 0;
}
AcWing 9. 分组背包问题
标签:背包问题 int clu pac bsp cin style div 分组
原文地址:https://www.cnblogs.com/QingyuYYYYY/p/11873187.html
评论