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 1126. Magnetic Storms

Why WA#6? This is my solution!
Posted by wayne 30 Apr 2009 11:36
program u1126;

var
  a:array[1..25000] of longint;
  n,max,i,j:longint;

begin
  readln(n); max:=-maxlongint;
  for i:=1 to n do
    begin
      readln(a[i]);
      if (a[i]=-1) and (i=1)
        then halt;
      if (a[i]=-1)
        then begin writeln(max); halt; end;
      if a[i]>max
        then max:=a[i];
    end;
  writeln(max);
  if max=a[1]
    then max:=a[2];
  i:=n+1;
  while true do
    begin
      readln(a[i]);
      if a[i]=-1
        then break;
      if a[i]>max
        then max:=a[i];
      writeln(max);
      if max=a[i-n+1]
        then max:=a[i-n+2];
      inc(i);
    end;
end.





I really can't find out where it wrongs!!