Pagini recente » Cod sursa (job #2117793) | Cod sursa (job #3240002) | Cod sursa (job #2490384) | Cod sursa (job #1912297) | Cod sursa (job #65336)
Cod sursa(job #65336)
var a,b:array[1..500000] of smallint;
n,k,i,j,st,fi,max,p,u:longint;
begin
assign(input,'secventa.in');
reset(input);
assign(output,'secventa.out');
rewrite(output);
readln(n,k);
st:=2;
fi:=1;
b[1]:=-31000;
max:=-31000;
for i:=1 to n do
begin
read(a[i]);
if (i>k)and(b[st]=a[i-k]) then inc(st);
inc(fi);
b[fi]:=a[i];
for j:=fi-1 downto st-1 do
begin
if not (b[j]>a[i]) then break;
end;
fi:=j+1;
b[fi]:=a[i];
if (i>=k)and(b[st]>max) then
begin
p:=i-k+1;
u:=i;
max:=b[st];
end;
end;
writeln(p,' ',u,' ',max);
close(output);
end.