Cod sursa(job #34948)

Utilizator petrePajarcu Alexandru-Petrisor petre Data 21 martie 2007 17:51:28
Problema Secventa Scor 0
Compilator fpc Status done
Runda Arhiva de probleme Marime 0.88 kb
var f,g:text;
a:array[0..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:=j-k+1;
                         while a[x-1]>a[poz] do dec(X);
                         l:=j;
                         while a[l+1]>a[poz] do inc(L);
                         end;
        end;
writeln(g,x,' ',l,' ',max);
close(F);
close(G);
end.