记录编号 |
48713 |
评测结果 |
AAAAAAAA |
题目名称 |
过河 |
最终得分 |
100 |
用户昵称 |
Abel·S |
是否通过 |
通过 |
代码语言 |
Pascal |
运行时间 |
0.922 s |
提交时间 |
2012-11-06 14:25:03 |
内存使用 |
38.35 MiB |
显示代码纯文本
program cojs_p1251;
var
f,p:array[0..20000,0..1000] of boolean;
i,j,k,l,m,n,t:longint;
procedure ass;
begin
assign(input,'rivera.in');
assign(output,'rivera.out');
reset(input);
rewrite(output);
end;
procedure cls;
begin
close(input);
close(output);
end;
procedure init;
var
i,j,k,t:longint;
a,b:array[0..1000] of longint;
begin
ass;
readln(n);
for i:=1 to n do
readln(a[i],b[i]);
for t:=1 to 20000 do
for i:=1 to n do
begin
if (t mod (a[i]+b[i])>a[i]) or (t mod (a[i]+b[i])=0)
then p[t,i]:=false
else p[t,i]:=true;
end;
for i:=1 to 20000 do
begin
p[i,n+1]:=true;
p[i,0]:=true;
end;
fillchar(f,sizeof(f),false);
end;
begin
init;
fillchar(f,sizeof(f),false);
f[0,0]:=true;
for t:=1 to 20000 do
for i:=0 to n do
begin
if f[t-1,i]
then begin
if i-5<=0 then
for j:=0 to i+5 do
if p[t,j] then f[t,j]:=true;
if (i-5>0) and (i+5<n+1) then
for j:=i-5 to i+5 do
if p[t,j] then f[t,j]:=true;
if i+5>=n+1
then begin writeln(t); cls; halt; end;
if p[t,i]
then f[t,i]:=true;
end;
end;
writeln('NO');
cls;
end.