Pagini recente » Cod sursa (job #560869) | Cod sursa (job #1340568) | Cod sursa (job #3265780) | Cod sursa (job #719925) | Cod sursa (job #227511)
Cod sursa(job #227511)
var f,g:text;
b:array[0..5000000] of char;
a:array[1..500000] of longint;
ok:boolean;
mini,n,i,j,k,l,max,min,poz,pozi,x,y:longint;
begin
assign(f,'secventa.in');
assign(g,'secventa.out');
reset(F);
rewrite(G);
readln(f,n,k);
n:=0;
read(f,b);i:=0;b[0]:='0';
while b[i] in (['0'..'9']+[' ']) do
begin
inc(I);
inc(n);
a[n]:=0;
ok:=false;
if b[i]='-' then begin
ok:=true;
i:=i+1;
end;
while (b[i]in ['0'..'9']) do
begin
a[n]:=a[n]*10+ord(b[i])-48;
inc(I);
end;
if ok then a[n]:=0-a[n];
end;
poz:=-1;
max:=-maxlongint;min:=0;
x:=0;
y:=0;
i:=0;
while i<n-k+1 do
begin
inc(I);
min:=maxlongint;
for j:=i to i+k-1 do
if (a[j]<min)then begin
min:=a[j];
poz:=j;
end
else if a[j]<max then poz:=j;
if min>max then begin
max:=min;
x:=i;
y:=i+k-1;
end;
if poz>i then i:=poz;
end;
writeln(g,x,' ',y,' ',max);
close(F);
close(G);
end.