Cod sursa(job #34933)

Utilizator petrePajarcu Alexandru-Petrisor petre Data 21 martie 2007 17:40:08
Problema Secventa Scor 0
Compilator fpc Status done
Runda Arhiva de probleme Marime 0.78 kb
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.