热心网友
回答时间:2024-12-31 01:44
var a:array[1..10000] of integer;
b:array[0..10000] of integer;
n,i,j,h:integer;
max:longint;
begin
max:=-maxlongint;
readln(n);
for i:=1 to n do read(a[i]);
b[1]:=1;b[0]:=0;
for i:=2 to n do
begin h:=0;
for j:=1 to i-1 do begin
if a[j]>=a[i] then
if b[h]<b[j] then h:=j;
b[i]:=b[h]+1;end;
end;
for i:=1 to n do if b[i]>max then max:=b[i];
writeln(max);
fillchar(b,sizeof(b),0); b[1]:=1;b[0]:=0;
for i:=2 to n do
begin h:=0;
for j:=1 to i-1 do begin
if a[j]<a[i] then
if b[h]<b[j] then h:=j;
b[i]:=b[h]+1;end;
end;
max:=-1;
for i:=1 to n do if b[i]>max then max:=b[i];
write(max);
end.
顶一下
收起