about summary refs log tree commit diff
path: root/others/volume1/038.pas
blob: a89142a818bd1eb2e6928c4b37e3d1d065093bd1 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
var
  n, l, h, l0, h0, len: int16;
  a: array of int32;

begin
  readln(n);
  setlength(a, n);
  for l := 0 to n - 1 do
    read(a[l]);
  len := 0;
  l0 := 0;
  h0 := 0;
  l := 0;
  while l < n do
    for h := l to n - 1 do
      if (h = n - 1) or
         ((a[h] mod a[h + 1]) * (a[h + 1] mod a[h]) > 0) then
        begin
          if len < h - l then
            begin
              len := h - l;
              l0 := l;
              h0 := h
            end;
          l := h + 1;
          break
        end;
  writeln(l0 + 1, ' ', h0 + 1)
end.