Cod sursa(job #194823)

Utilizator nod_softwareBudisteanu Ionut Alexandru nod_software Data 14 iunie 2008 16:42:30
Problema Secventa Scor 0
Compilator fpc Status done
Runda Arhiva de probleme Marime 1.1 kb
program secventa;
  
{$APPTYPE CONSOLE}  
  
uses
  SysUtils;

type vector = array [1..500000] of integer;
var v:vector;      
    q,min,i,j,k,x,y,n:longint;
    max,max2,lungime:integer;
    fin,fout:text;
{*----------------------------*}
function minim:integer;
begin
        min:=maxint;
        for q:=i to j do
        begin
                if min > v[q] then min:=v[q];
        end;
end;
{*----------------------------*}
begin  
  assign(fin,'secventa.in');      
  assign(fout,'secventa.out');      
  reset(fin);      
  rewrite(fout);      
  readln(fin,n,k);      
  for i:=1 to n do read(fin,v[i]);
  max:=-maxint;   
  i:=0;   
  while i < n do  
  begin  
        inc(i);   
        j:=i;   
        while ((v[i]<v[j+1]) and (j<n)) do  
        begin  
                inc(j);
                if ((max < minim) and (j-i+1>=k)) then
                begin
                        max:=v[i];
                        x:=i;
                        y:=j;
                end;
        end;
  end;   
  writeln(fout,x,' ',y,' ',max);      
  close(fout);      
end.