Cod sursa(job #289794)

Utilizator andreirulzzzUPB-Hulea-Ionescu-Roman andreirulzzz Data 26 martie 2009 23:36:45
Problema Subsir crescator maximal Scor 20
Compilator fpc Status done
Runda aa Marime 0.8 kb
program scmax;
var f:text;
    a:array[1..100000] of longint;
    i,j,pos,n,posmax,lf:longint;
procedure sccr;
begin
      if a[i]-a[i-1]>0 then
         inc(pos);
      if a[i]-a[i-1]<0 then
          begin
           if pos>posmax then begin
              posmax:=pos;
              lf:=i-posmax;
              end;
           pos:=1;
           end;
      if a[i]-a[i-1]=0 then dec(i);
end;
begin
posmax:=1;
assign(f,'scmax.in');
reset(f);
read(f,n);
pos:=1;  i:=1;
read(f,a[1]);
while not eof(f) do begin
      inc(i); read(f,a[i]); sccr;
      end;
close(f);
if pos>posmax then begin           
   posmax:=pos;               
   lf:=i-posmax+1;
   end;
assign(f,'scmax.out');
rewrite(f);
writeln(f,posmax);
for i:=lf to lf+posmax-1 do
    write(f,a[i],' ');
close(f);
end.