| 记录编号 | 551160 | 评测结果 | AAAAAAAAAAA | ||
|---|---|---|---|---|---|
| 题目名称 | 395.[USACO Oct09] Bessie 的体重问题 | 最终得分 | 100 | ||
| 用户昵称 | 是否通过 | 通过 | |||
| 代码语言 | C++ | 运行时间 | 0.264 s | ||
| 提交时间 | 2020-04-20 10:41:57 | 内存使用 | 13.83 MiB | ||
#include <iostream>
#include <cstdio>
using namespace std;
int h,n,f[45001]={0},s;
int main()
{
freopen("diet.in","r",stdin);
freopen("diet.out","w",stdout);
scanf("%d%d",&h,&n);
for(int q=1;q<=n;q++) {
scanf("%d",&s);
for(int w=h;w>=s;w--) {
if (f[w-s]+s>f[w]) f[w]=f[w-s]+s;
}
}
printf("%d\n",f[h]);
return 0;
}