Cod sursa(job #593710)
| Utilizator | Data | 4 iunie 2011 12:19:07 | |
|---|---|---|---|
| Problema | Secventa | Scor | 0 |
| Compilator | fpc | Status | done |
| Runda | Arhiva de probleme | Marime | 0.46 kb |
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(i-k+1,' ',i,' ',max);
end.
