Pagini recente » Cod sursa (job #1493973) | Cod sursa (job #2432225) | Cod sursa (job #2398725) | Cod sursa (job #891243) | Cod sursa (job #34933)
Cod sursa(job #34933)
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;min:=0;
x:=0;
l:=0;
while poz<n do
begin
inc(poz);
mini:=maxlongint;
for j:=poz to poz+k-1 do
if (a[j]<mini)then begin
mini:=a[j];
poz:=j;
end;
if mini>max then begin
max:=mini;
x:=poz;
l:=poz+k-1;
end;
end;
writeln(g,x,' ',l,' ',max);
close(F);
close(G);
end.