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

WA #5
Posted by Swifty 16 Mar 2009 19:15
var  a:array [1..100] of integer;
     n,x,i,j,m,x1,x2,min1,min2:integer;
begin
  readln(n,x);
  m:=0;
  min1:=maxint;
  min2:=maxint;
  for i:=1 to n do
    begin
      read(a[i]);
      if (a[i]>x)and(a[i]<0) then
                               begin
                                 writeln('Impossible');
                                 readln;
                                 halt;
                               end;
      if (a[i]<x)and(a[i]>0) then
                               begin
                                 writeln('Impossible');
                                 readln;
                                 halt;
                               end;
      if (a[i]>0)and(a[i]<min1) then
                                  begin
                                    min1:=a[i];
                                  end;

      if (a[i]<0)and(a[i]<min2) then
                                  begin
                                    min2:=a[i];
                                  end;
    end;
  if (x<0)and(min1=maxint) then
                             begin
                               writeln(abs(x),' ',abs(x));
                               readln;
                               halt;
                             end;
  if (x>0)and(min2=maxint) then
                             begin
                               writeln(abs(x),' ',abs(x));
                               readln;
                               halt;
                             end;
  if x<0 then
           begin
             x1:=(min1*2)+abs(x);
             x2:=abs(x);
           end;
  if x>0 then
           begin
             x1:=x;
             x2:=(abs(min2)*2)+x;
           end;
  if x=0 then
           begin
             x1:=0;
             x2:=0;
           end;
  writeln(x1,' ',x2);
  readln;
end.


I can't understand what is wrong here?

Edited by author 16.03.2009 19:29
Re: WA #5
Posted by Swifty 16 Mar 2009 19:28
Can anyone give me some tests???
Re: WA #5
Posted by Ras Misha [t4ce] 21 Mar 2009 19:52
i can give you my ac solution