记录编号 7878 评测结果 AWAWWWWWAE
题目名称 美酒节赛羊 最终得分 30
用户昵称 Gravatarzxc111 是否通过 未通过
代码语言 Pascal 运行时间 1.645 s
提交时间 2008-11-12 11:29:15 内存使用 43.03 MiB
显示代码纯文本
program ooo;
var
i,j,k,n,m,s,p,min:longint;
a,c:array[0..5000010] of longint;
f:array[0..5000010] of boolean;
t:text;
b:array[1..3,1..2] of longint;
begin
fillchar(a,sizeof(a),0);
fillchar(b,sizeof(b),0);
fillchar(f,sizeof(f),false);
assign(t,'goat.in');
reset(t);
readln(t,s,p);
close(t);
b[1,1]:=1;b[1,2]:=-1;
b[2,1]:=5;b[2,2]:=2;
b[3,1]:=10;b[3,2]:=5;
c[0]:=p;
for i:=0 to s do
 for j:=1 to 3 do
 begin
  if (c[i]=0)and(f[i+10]=true)and(a[i]+10<=a[i+10])
   then begin a[i+10]:=a[i]+10;c[i+10]:=0;end;
  if (f[i+b[j,1]]=false) then
   if (c[i]-b[j,2]>=0)and(c[i]-b[j,2]<=p) then
    begin
     a[i+b[j,1]]:=a[i]+1;
     f[i+b[j,1]]:=true;
     c[i+b[j,1]]:=c[i]-b[j,2];
    end else else
  if c[i]-b[j,2]>=0 then
   if (c[i+b[j,1]]>c[i]-b[j,2])and(a[i+b[j,1]]>a[i]+1) then
    begin
     a[i+b[j,1]]:=a[i]+1;
     c[i+b[j,1]]:=c[i]-b[j,2];
    end;
 end;
min:=maxlongint;
for i:=s to s+5 do
 if (a[i]<>0)and(a[i]<min) then min:=a[i];
assign(t,'goat.out');
rewrite(t);
write(t,min);
close(t);
end.