ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Discussion of Problem 1642. 1D Maze

what's wrong? on my pc it works right... (Pascal)
Posted by jss94 14 Oct 2012 19:03
var
n,i,k:byte;
x,d,y:integer;
m:array[0..100] of integer;
begin
read(n,x);
for i:=1 to n do
read(m[i]);
k:=0;
y:=n;

if x<0 then begin

for i:=1 to y do begin
if (m[i]>x) and (m[i]<0) then
begin writeln('Impossible'); k:=k+1;end
else
begin if m[i]<0 then begin y:=abs(x); end;
if m[i]>0 then d:=m[i];
end;
if m[i]<d then d:=m[i];end;
writeln(d+d+abs(x));
writeln(y);

end;

if x>0 then begin
for i:=1 to n do begin
if (m[i]<x) and (m[i]>0) then begin writeln('Impossible'); k:=k+1;end
else
begin if (m[i]>x) and (m[i]>0) then begin d:=x; writeln(d);end;
if m[i]<0 then d:=m[i];end;
if (m[i]<0) and (m[i]>d) then d:=m[i];
end;
writeln(abs(d)+abs(d)+x);
end;




end.