| 记录编号 | 443410 | 评测结果 | AAAAAAAAAAA | ||
|---|---|---|---|---|---|
| 题目名称 | 395.[USACO Oct09] Bessie 的体重问题 | 最终得分 | 100 | ||
| 用户昵称 | 是否通过 | 通过 | |||
| 代码语言 | C++ | 运行时间 | 0.065 s | ||
| 提交时间 | 2017-08-30 19:49:55 | 内存使用 | 0.48 MiB | ||
# include <cstdio>
# include <algorithm>
# define MAXN 45023
using namespace std;
int f[MAXN], n, m, *a = new int();
int main() {
freopen("diet.in", "r", stdin);
freopen("diet.out", "w", stdout);
scanf("%d %d", &n, &m);
for(int i = 1; i <= m; i++) {
scanf("%d", a);
for(int j = n; j >= *a; j--) {
f[j] = max(f[j], f[j - *a] + *a);
}
}
printf("%d\n", f[n]);
}