SlepoiKrot

Untitled

Dec 6th, 2017
82
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. program maxxlocal;
  2.  
  3. {$APPTYPE CONSOLE}
  4.  
  5. uses
  6.   SysUtils;
  7.  
  8. var
  9.   n, n1, n2, i, i1, loc: integer;
  10. begin
  11.   readln (n, n1, n2);
  12.   loc := 0;
  13.   i := 0;
  14.   i1 := 100000000;
  15.   while (n2 <> 0) do begin
  16.    if ((n1 > n) and (n1 > n2)) then begin
  17.     inc (loc);
  18.     n := n1;
  19.     n1 := n2;
  20.     readln (n2);
  21.     i := 0;
  22.     while (((n1 <= n) or (n1 <= n2)) and (n2 <> 0)) do begin
  23.       inc (i);
  24.       n := n1;
  25.       n1 := n2;
  26.       readln (n2);
  27.     end;
  28.     if ((i <> 0) and (i < i1) and ((n1 > n) and (n1 > n2))) then begin
  29.       i1 := i;
  30.     end;
  31.    end
  32.    else begin
  33.     n := n1;
  34.     n1 := n2;
  35.     readln (n2);
  36.    end;
  37.   end;
  38.   if (loc >= 2) then
  39.     writeln (i1 + 1)
  40.   else
  41.     writeln (0);
  42.   readln;
  43. end.
RAW Paste Data