Pagini recente » Cod sursa (job #170828) | Istoria paginii runda/fireball3 | Cod sursa (job #1581340) | Cod sursa (job #1719314) | Cod sursa (job #289976)
Cod sursa(job #289976)
program secventa;
var n,k,min,i,j,poz,max,pozi,x,y:longint;
a:array[1..500024] of longint;
b:array[0..5000000] of char;
ok:boolean;
procedure citire;
begin
assign(input,'secventa.in');
reset(input);
readln(input,n,k);
n:=0; read(input,b);i:=0;b[0]:='0';
end;
begin
citire;
while b[i] in (['0'..'9']+[' ']) do begin
inc(i);inc(n);a[n]:=0;ok:=false;
if b[i]='-' then begin ok:=true;inc(i);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;
close(input);
assign(output,'secventa.out');
rewrite(output);
write(output,x,' ',y,' ',max);
close(output);
end.