Pagini recente » Cod sursa (job #632937) | Cod sursa (job #1661424) | Cod sursa (job #2903002) | Cod sursa (job #3238580) | Cod sursa (job #593667)
Cod sursa(job #593667)
var a:array[1..500000] of integer;
n,k,min,max,i,j,p,m:integer;
begin
assign(input,'secventa.in');reset(input);
assign(output,'secventa.out');rewrite(output);
readln(n,m);
max:=0;
for i:=1 to n do read(a[i]);
i:=1;
while i<=n-m+1 do
begin
min:=maxint;
for j:=i to i+m-1 do
if a[j]<=min then
begin
min:=a[j];
k:=j;
end;
if min>max then
begin
max:=min;
p:=i;
end;
i:=k+1;
end;
writeln(p,' ',p+m
-1,' ',max);
close(output);
end.