比赛 NOIP2008集训模拟2 评测结果 MMMMMMMMMM
题目名称 美酒节赛羊 最终得分 0
用户昵称 Achilles 运行时间 0.000 s
代码语言 Pascal 内存使用 0.00 MiB
提交时间 2008-11-11 09:42:38
显示代码纯文本
program goat;
var
  sz:array[0..500000,0..100]of 0..25000000;
  s,p,i,j,min:longint;
begin
  assign(input,'goat.in');
  assign(output,'goat.out');
  reset(input);
  rewrite(output);
  readln(s,p);
  for i:=0 to s do
    for j:=0 to p do
      sz[i,j]:=24000000;
  sz[0,0]:=0;
  for j:=1 to s do
    for i:=1 to p do
    begin
      if (j-5>=0)and(i-2>=0) then if sz[j-5,i-2]+1<sz[j,i] then sz[j,i]:=sz[j-5,i-2]+1;
      if (j-10>=0)and(i-5>=0) then if sz[j-10,i-5]+1<sz[j,i] then sz[j,i]:=sz[j-10,i-5]+1;
      if i+1<=p then if sz[j-1,i+1]+1<sz[j,i]
        then sz[j,i]:=sz[j-1,i+1]+1;
    end;
  min:=2147483647;
  for i:=1 to p do
    if sz[s,i]<min then min:=sz[s,i];
  writeln(min);
  close(input);
  close(output);
end.