| 记录编号 | 238161 | 评测结果 | AAAAAAAAAAA | ||
|---|---|---|---|---|---|
| 题目名称 | 395.[USACO Oct09] Bessie 的体重问题 | 最终得分 | 100 | ||
| 用户昵称 | 是否通过 | 通过 | |||
| 代码语言 | C++ | 运行时间 | 0.029 s | ||
| 提交时间 | 2016-03-18 18:31:37 | 内存使用 | 0.46 MiB | ||
#include<cstdlib>
#include<cstdio>
using namespace std;
const int maxn=45010;
int n,m;
int f[maxn]={0};
void chul();
int getmax(int,int);
int main()
{
freopen("diet.in","r",stdin);
freopen("diet.out","w",stdout);
chul();
}
void chul()
{
scanf("%d%d",&n,&m);
for(int i=1;i<=m;i++)
{
int w;
scanf("%d",&w);
for(int i=n;i>=w;i--)
{
f[i]=getmax(f[i],f[i-w]+w);
}
}
printf("%d",f[n]);
}
int getmax(int x,int y)
{
if(x>y)return x;
return y;
}