Pagini recente » Cod sursa (job #653697) | Cod sursa (job #662437) | Cod sursa (job #2339203) | Cod sursa (job #553275) | Cod sursa (job #34728)
Cod sursa(job #34728)
var f,g:text;
a:array[1..500000] of longint;
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);
for i:=1 to n do
read(f,a[i]);
poz:=0;
max:=0;
k:=0;
l:=0;
while i<n do
begin
inc(poz);
if min=max then pozi:=poz
else
pozi:=poz+1;
mini:=maxlongint;
for j:=pozi to pozi+k-1 do
if (a[j]<mini)then begin
mini:=a[j];
poz:=j;
end;
if mini>max then begin
max:=mini;
k:=pozi;
l:=pozi+1;
end;
if poz<=pozi then poz:=pozi+k-1;
end;
writeln(g,k,l,max);
close(F);
close(G);
end.