| 记录编号 | 14704 | 评测结果 | AAAAAAAAAAA | ||
|---|---|---|---|---|---|
| 题目名称 | 395.[USACO Oct09] Bessie 的体重问题 | 最终得分 | 100 | ||
| 用户昵称 | 是否通过 | 通过 | |||
| 代码语言 | Pascal | 运行时间 | 1.300 s | ||
| 提交时间 | 2009-11-03 15:09:50 | 内存使用 | 86.12 MiB | ||
program jianfeijihua;
var
m,n,i,j:longint;
a:array[1..500]of integer;
f:array[0..500,0..45000] of longint;
function max(c,b:longint):longint;
begin
if c>b then
max:=c
else
max:=b
end;
begin
assign (input,'diet.in');
reset (input);
assign (output,'diet.out');
rewrite (output);
readln (m,n);
for i:=1 to n do
readln (a[i]);
for i:=1 to n do
for j:=1 to m do
if j-a[i]>=0 then
f[i,j]:=max(f[i-1,j],f[i-1,j-a[i]]+a[i])
else
f[i,j]:=f[i-1,j];
writeln (f[n,m]);
close (input);
close (output)
end.