Pagini recente » Atasamentele paginii Profil danimad2011 | Cod sursa (job #278337) | Cod sursa (job #593716)
Cod sursa(job #593716)
var a,d:array[1..500000] of integer;
n,k,i,p,u,max,x,y,t:longint;
begin
assign(input,'secventa.in');reset(input);
assign(output,'secventa.out');rewrite(output);
readln(n,k);
for i:=1 to n do read(a[i]);
p:=1;u:=0;max:=-maxint;
for i:=1 to n do
begin
while (p<=u) and (a[i]<a[d[u]]) do dec(u);
inc(u);
d[u]:=i;
if i-d[p]=k then inc(p);
if (i>=k) and (a[d[p]]>max) then
begin
max:=a[d[p]];
t:=i;
end;
end;
writeln(t-k+1,' ',t,' ',max);
close(output);
end.