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 I got WA? Who can help me,and give me some hints?
Posted by qwt 6 Apr 2002 19:25
var
  a:array[0..14000] of integer;
  b:array[0..32767] of integer;
  n,i,j,k,max:integer;

begin
  readln(n);
  fillchar(a,sizeof(a),0);fillchar(b,sizeof(b),0);    b[0]:=1;max:=0;
  for i:=0 to n-2 do begin
    readln(a[i]);
    if a[i]=-1 then begin writeln(max);halt;end;
    inc(b[a[i]]);
    if a[i]>max then max:=a[i];
  end;
  readln(j);
  while j>=0 do begin
    inc(i);
    i:=i mod n;
    dec(b[a[i]]);a[i]:=j;
    inc(b[j]);
    if j>max then max:=j;
    k:=max;
    if b[max]=0 then for max:=k-1 downto 0 do if b[max]>0 then break;
    writeln(max);
    readln(j);
  end;
end.
Re: Why I got WA? Who can help me,and give me some hints?
Posted by MadPsyentist/Sam 8 Apr 2002 01:50
If you explain the idea of your solution, I might be able to give a hint.

Anyway, I compiled your program under FreePascal and it produces
nothing for this little case. Is it the same on your side?
1
38197
11776
80610
-1
But M>1
Posted by Koala 13 Feb 2003 10:54
> If you explain the idea of your solution, I might be able to give
a hint.
>
> Anyway, I compiled your program under FreePascal and it produces
> nothing for this little case. Is it the same on your side?
> 1
> 38197
> 11776
> 80610
> -1