q.we@@@ 2012-10-23 22:31:00
点我顶贴
收藏
删除
var a,o,c:array[0..1001]of longint;
i,n,s,j,d:longint;
begin
n:=0;
while not eoln do
begin
inc(n);
read(a[n]);
end;
a[0]:=maxlongint;
for i:=1 to n do
for j:=0 to i-1 do
if (a[j]>a[i])and(o[j]+1>o[i]) then o[i]:=o[j]+1;
a[0]:=-maxlongint;
for i:=1 to n do
for j:=0 to i-1 do
if (a[j]<a[i])and(c[j]+1>c[i]) then c[i]:=c[j]+1;
s:=-maxlongint;d:=-maxlongint;
for i:=1 to n do
begin
if o[i]>s then s:=o[i];
if c[i]>d then d:=c[i];
end;
writeln(s,' ',d);
end.