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