记录编号 |
7876 |
评测结果 |
WWAWWAWWAT |
题目名称 |
美酒节赛羊 |
最终得分 |
30 |
用户昵称 |
bly1991 |
是否通过 |
未通过 |
代码语言 |
Pascal |
运行时间 |
2.815 s |
提交时间 |
2008-11-12 08:01:14 |
内存使用 |
0.87 MiB |
显示代码纯文本
program bly(input,output);
var
a,b:array[0..100000] of longint;
x:array[1..4] of longint;
s,p,ans,time,max:longint;
p0:boolean;
i,j:longint;
f1,f2:text;
procedure max1(x1,x2,x3,x4:longint);
var
i0:longint;
begin
max:=0;
x[1]:=x1; x[2]:=x2; x[3]:=x3; x[4]:=x4;
for i0:=1 to 4 do if x[i0]>max then max:=x[i0];
b[i]:=max;
end;
procedure max2(x1,x2,x3,x4:longint);
var
i0:longint;
begin
max:=0;
x[1]:=x1; x[2]:=x2; x[3]:=x3; x[4]:=x4;
for i0:=1 to 4 do if x[i0]>max then max:=x[i0];
a[i]:=max;
end;
begin
assign(f1,'goat.in');
reset(f1);
readln(f1,s,p);
close(f1);
ans:=0;
p0:=false;
repeat
inc(time);
for i:=1 to p do begin
if (i>=2)and(i<5) then max1(a[i+1]+1,a[i-2]+5,0,a[0]+1);
if i>=5 then max1(a[i+1]+1,a[i-2]+5,a[i-5]+10,a[0]+1);
if i<2 then max1(a[i+1]+1,0,0,a[0]+1);
if b[i]=s then begin ans:=time; p0:=true; break; end;
end;
inc(time);
for i:=1 to p do begin
if (i>=2)and(i<5) then max2(b[i+1]+1,b[i-2]+5,0,b[0]+1);
if i>=5 then max2(b[i+1]+1,b[i-2]+5,b[i-5]+10,b[0]+1);
if i<2 then max2(b[i+1]+1,0,0,b[0]+1);
if a[i]=s then begin ans:=time; p0:=true; break; end;
end;
until (ans<>0)or(p0=true);
assign(f2,'goat.out');
rewrite(f2);
writeln(f2,ans);
close(f2);
end.