比赛 NOIP2008集训模拟2 评测结果 MMMMMMMMMM
题目名称 美酒节赛羊 最终得分 0
用户昵称 lc 运行时间 0.000 s
代码语言 Pascal 内存使用 0.00 MiB
提交时间 2008-11-11 11:27:50
显示代码纯文本
program ee2;
 var
     ss,p,i:longint;
     m,s,t:array[1..25000004] of longint;


begin
 assign(input,'goat.in');
 assign(output,'goat.out');
 reset(input); rewrite(output);
  readln(ss,p);
  m[1]:=0; s[1]:=0; t[1]:=0;
  for i:=1 to ss-1 do
    begin
    if s[i]>=ss then begin writeln(i-1); exit end;
    if (m[i]+5<p) or (m[i]+5=p) and (s[i]+10>=ss)
                     then begin
                     m[i+1]:=m[i]+5;
                     s[i+1]:=s[i]+10
                     end
    else
    if (m[i]+2<p) or (m[i]+2=p)and (s[i]+5>=ss)
                then
                     begin
                     m[i+1]:=m[i]+2;
                     s[i+1]:=s[i]+5
                     end
    else begin
         m[i+1]:=m[i]-1;
         s[i+1]:=s[i]+1
         end;
   end;
   close(input); close(output);
end.