ENG  RUSTimus Online Judge
Online Judge
Задачи
Авторы
Соревнования
О системе
Часто задаваемые вопросы
Новости сайта
Форум
Ссылки
Архив задач
Отправить на проверку
Состояние проверки
Руководство
Регистрация
Исправить данные
Рейтинг авторов
Текущее соревнование
Расписание
Прошедшие соревнования
Правила
вернуться в форум

Обсуждение задачи 1126. Магнитные бури

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.
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
Koala But M>1 // Задача 1126. Магнитные бури 13 фев 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