Pagini recente » Cod sursa (job #1788349) | Cod sursa (job #2746586) | Cod sursa (job #615755) | Cod sursa (job #1689275) | Cod sursa (job #48651)
Cod sursa(job #48651)
{
Program secventa
}
Program secv;
Var n, k, i, q, pr, ul : Longint;
nr : array[0..500000] of integer;
poz : array[1..500000] of 1..500000;
el, max : integer;
Begin
Assign( input, 'secventa.in' );
Reset( input );
Readln( n, k );
pr := 1;
ul := 1;
nr[0] := -MaxInt;
max := -MaxInt;
q := 1;
For i := 1 to k-1 do
Begin
Read( el );
While ( ul > pr-1 ) and ( el < nr[ul] ) do ul := ul-1;
ul := ul+1;
nr[ul] := el;
poz[ul] := i;
End;
For i := k to n do
Begin
Read( el );
While ( ul > pr-1 ) and ( el < nr[ul] ) do ul := ul-1;
ul := ul+1;
nr[ul] := el;
poz[ul] := i;
if i - poz[pr] >= k then pr := pr+1;
if nr[pr] > max then
Begin
q := i-k+1;
max := nr[pr];
End;
End;
Close( input );
Assign( output, 'secventa.out' );
Rewrite( output );
Writeln( q, ' ', q+k-1, ' ', max );
Close( output );
End.