记录编号 | 14697 | 评测结果 | AAAAAAAAAAA | ||
---|---|---|---|---|---|
题目名称 | 395.[USACO Oct09] Bessie 的体重问题 | 最终得分 | 100 | ||
用户昵称 | 是否通过 | 通过 | |||
代码语言 | Pascal | 运行时间 | 0.225 s | ||
提交时间 | 2009-11-03 14:26:47 | 内存使用 | 0.28 MiB | ||
program diet; var a:array[0..500] of longint; f:array[0..45000] of longint; h,n,i,v:longint; begin assign(input,'diet.in'); reset(input); assign(output,'diet.out'); rewrite(output); readln(h,n); for i:=1 to n do readln(a[i]); fillchar(f,sizeof(f),0); for i:=1 to n do for v:=h downto a[i] do if f[v]<f[v-a[i]]+a[i] then f[v]:=f[v-a[i]]+a[i]; writeln(f[h]); close(input); close(output) end.