Cod sursa(job #194838)
program secventa;
{$APPTYPE CONSOLE}
uses
SysUtils;
type vector = array [1..500000] of integer;
var v:vector;
q,i,j,k,x,y,n:longint;
min,max,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;
minim:=min;
end;
{*----------------------------*}
begin
assign(fin,'secventa.in');reset(fin);
assign(fout,'secventa.out');rewrite(fout);
readln(fin,n,k);
for i:=1 to n do read(fin,v[i]) ;
max:=-maxint;
i:=0;
while i <= n-k do
begin
inc(i);
j:=i;
while (j<n) do
begin
inc(j);
if ((max < minim) and (j-i+2>=k)) then
begin
max:=minim;
x:=i;
y:=j;
end;
end;
end;
writeln(fout,x,' ',y,' ',max);
close(fout);
end.