标签:背包 max def sso print ace iostream ios mes
#include <iostream>
#include <cstdio>
using namespace std;
//Mystery_Sky
//完全背包模板
#define M 1010
int f[M], c[M], w[M];
int v, m, ans;
int main() {
scanf("%d%d", &v, &m);
for(int i = 1; i <= m; i++) scanf("%d%d", &c[i], &w[i]);
for(int i = 1; i <= m; i++)
for(int j = c[i]; j <= v; j++)
f[j] = max(f[j], f[j-c[i]]+w[i]);
printf("max=%d\n", f[v]);
return 0;
}
标签:背包 max def sso print ace iostream ios mes
原文地址:https://www.cnblogs.com/Benjamin-cpp/p/10841001.html