Cod sursa(job #805886)

Utilizator tgistvanTorok Istvan tgistvan Data 1 noiembrie 2012 13:54:05
Problema Subsir crescator maximal Scor 70
Compilator fpc Status done
Runda Arhiva educationala Marime 1.12 kb
type sor=array[-1..50000]of int64;
var f,g:text;
    n,i,j,x,y: longint;
    a,b,c:sor;
procedure fordir(y,x:longint);
begin
if x>0 then begin
            fordir(c[y],x-1);
            write(g,a[y],' ');
            end;
end;


begin

assign(f,'scmax.in');
reset(f);
readln(f,n);
x:=0;
for i:=1 to n do begin read(f,a[i]);
{if a[i]>x then }
for j:=0 to i do if (b[j]>=b[i]) and (a[j]<a[i]) then begin
                                                      b[i]:=b[j]+1;
                                                      c[i]:=j;
                                                      if b[i]>x then begin
                                                                     x:=b[i];
                                                                     y:=i;
                                                                     end;
                                                      end;
end;
close(f);



assign(g,'scmax.out');
rewrite(g);
writeln(g,x);
fordir(y,x);
{
for i:=1 to x do begin
                 write(a[y],' ');
                 y:=c[y];
                 end;
}
close(g);

end.