#1 ahfy_zyt@2011-10-07 08:08:00
22862
回复
删除
话归正题
program buylow;
var
a,len,t:array [0..5000] of longint;
i,j,k,l:longint;
n,maxlen:longint;
begin
readln(n);
for i:=1 to n do read(a[i]);
for i:=1 to n do len[i]:=1;
for i:=n-1 downto 1 do begin
for j:=i+1 to n do
if (a[i]>a[j]) and (len[j]>=len[i]) then len[i]:=len[j]+1; end;
maxlen:=1;
for i:=1 to n do
if len[i]>maxlen then maxlen:=len[i];
a[0]:=maxlongint;
len[0]:=maxlen+1;
for i:=1 to n do if len[i]=1 then t[i]:=1 else t[i]:=0;
for l:=1 to maxlen do
begin
for i:=n downto 1 do if len[i]=l then
begin
j:=i-1;
while (j>=0) and (a[i]<>a[j]) do
begin
if (a[j]>a[i]) and (len[j]=l+1) then t[j]:=t[i]+t[j];
j:=j-1;
end;
end;
end;
writeln(maxlen,' ',t[0]);
readln;
readln;
end.