xiaozqh
[srcbox.git] / rqnoj / rqnoj217.pas
blob88264faa16360d4efa4dee114a5a47f76ad32eba
1 var
2 n,i,j,max:longint;
3 a,f:array [0..1000] of longint;
5 begin
6 readln(n);
7 for i:=1 to n do begin read(a[i]); f[i]:=1; end;
8 max:=1;
9 for i:=1 to n do
10 for j:=i-1 downto 1 do
11 if a[j]>a[i] then
12 begin
13 if f[i]<f[j]+1 then f[i]:=f[j]+1;
14 if f[i]>max then max:=f[i];
15 end;
16 write(max,' ');
17 for i:=1 to n do f[i]:=1; max:=1;
18 for i:=1 to n do
19 for j:=i-1 downto 1 do
20 if a[j]<a[i] then
21 begin
22 if f[i]<f[j]+1 then f[i]:=f[j]+1;
23 if f[i]>max then max:=f[i];
24 end;
25 writeln(max);
26 end.