Cod sursa(job #1113180)
| Utilizator | Data | 20 februarie 2014 13:34:51 | |
|---|---|---|---|
| Problema | Subsir crescator maximal | Scor | 70 |
| Compilator | fpc | Status | done |
| Runda | Arhiva educationala | Marime | 0.51 kb |
Program subsir;
var a,b:array[1..100000] of longint;
i,j,n,max:longint;
f,q:text;
begin
assign(f,'scmax.in');
reset(f);
assign(q,'scmax.out');
rewrite(q);
readln(f,n);
max:=0;
for i:=1 to n do read(f,a[i]);
for i:=n downto 1 do
begin
b[i]:=1;
for j:=i+1 to n do
if (a[i]<a[j]) and (b[i]<b[j]+1) then b[i]:=b[j]+1;
if b[i]>max then max:=b[i];
end;
writeln(q,max);
for i:=1 to n do if b[i]=max then begin write(q,a[i],' '); dec(max); end;
close(f);
close(q);
end.
