Pagini recente » Cod sursa (job #1154798) | Cod sursa (job #1713631) | Cod sursa (job #2573553) | Cod sursa (job #993344) | Cod sursa (job #289979)
Cod sursa(job #289979)
var b:array[0..5000000] of char;
min,poz,pozi,x,y,mini,n,i,j,k,l,max:longint;
a:array[1..500000] of longint;
ok:boolean;
begin
assign(input,'secventa.in');assign(output,'secventa.out');
reset(input);rewrite(output);readln(input,n,k);n:=0;
read(input,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;
if min>max then begin max:=min;x:=i;y:=i+k-1;end;
if poz>i then i:=poz;
end;
writeln(output,x,' ',y,' ',max);
close(input);
close(output);
end.