完全背包问题
完全背包模板题
#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
", f[v]);
return 0;
}