Cod sursa(job #273254)

Utilizator andreirulzzzUPB-Hulea-Ionescu-Roman andreirulzzz Data 8 martie 2009 13:13:09
Problema Subsir crescator maximal Scor 5
Compilator fpc Status done
Runda Arhiva educationala Marime 0.73 kb
program scmax;
var f:text;
    a:array[1..100000] of integer;
    i,j,pos,n,posmax,lf:integer;
begin
posmax:=1;
assign(f,'scmax.in');
reset(f);
read(f,n);
pos:=0;              
read(f,a[1]);
for i:=2 to n do begin
      read(f,a[i]);     
      if a[i]>a[i-1] then
         inc(pos)
      else if a[i]<a[i-1] then
          begin
           if pos>posmax then begin
              posmax:=pos;
              lf:=i-posmax+1;
              end;
           pos:=1;
           end
          else dec(n);
      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-2 do
    writeln(f,a[i],' ');
close(f);
end.