比赛 |
NOIP2008集训模拟2 |
评测结果 |
AAAAAWAAAA |
题目名称 |
美酒节赛羊 |
最终得分 |
90 |
用户昵称 |
WaterFire |
运行时间 |
0.000 s |
代码语言 |
Pascal |
内存使用 |
0.00 MiB |
提交时间 |
2008-11-11 09:26:08 |
显示代码纯文本
program waterfire;
const
fin='goat.in';
fout='goat.out';
var
i,j,s,p,n,m,time:longint;
f,g:text;
Procedure Work;
var
ii,jj:longint;
Begin
while m<s do begin
while n<p-5 do
begin
inc(n,5);
inc(m,10);
inc(time);
if m>=s then exit;
end;
while p<=5 do
begin
if (p-n>2) then
begin
inc(n,2);
inc(m,5);
inc(time);
end else
if (p-n=2)and(s-m<=5) then
begin
inc(n,2);
inc(m,5);
inc(time);
end else
begin
dec(n);
inc(m);
inc(time);
end;
if m>=s then exit;
end;
if (n=p-5)and(s-m<=10) then
begin
inc(n,5);
inc(m,10);
inc(time);
end else
if (p-n<4)and(p-n>=2)and(s-m<=5) then
begin
inc(n,2);
inc(m,5);
inc(time);
end else begin
dec(n,1);
inc(m,1);
inc(time);
end;
end;
End;
BEGIN
n:=0;m:=0;time:=0;
assign(f,fin);reset(f);
assign(g,fout);rewrite(g);
read(f,s,p);
work;
writeln(g,time);
close(f);close(g);
END.