比赛 20091103 评测结果 AAAAAAAAAAA
题目名称 Bessie 的体重问题 最终得分 100
用户昵称 ReimBurSe. 运行时间 0.000 s
代码语言 Pascal 内存使用 0.00 MiB
提交时间 2009-11-03 10:17:25
显示代码纯文本
Program diet;

Type
sc=array [1..500] of longint;
sc1=array [0..500,0..45000] of longint;

Var
s:sc;
a:sc1;
i,j:longint;
m,n:longint;

Begin
assign(input,'diet.in');
assign(output,'diet.out');
reset(input);
rewrite(output);
readln(m,n);
for i:=1 to n do readln(s[i]);
for i:=0 to n do
 for j:=0 to m do
  a[i,j]:=0;
for i:=1 to n do begin
 for j:=1 to m do begin
   a[i,j]:=a[i-1,j];
  if j>=s[i] then begin
   if a[i-1,j-s[i]]+s[i]>a[i,j] then
    a[i,j]:=a[i-1,j-s[i]]+s[i];
  end;
 end;
end;
writeln(a[n,m]);
close(input);
close(output);
End.