0
已解决
var
n,i,j,ans:longint;
a,f:array [0..1000] of longint;
begin
while not eof do
begin
ans:=0;
readln(n);
for i:=1 to n do read(a[i]);
for i:=2 to n do
begin
f[i]:=1;
for j:=1 to i-1 do
begin
if (a[i]>a[j]) and (f[j]+1>f[i]) then
f[i]:=f[j]+1;
end;
if f[i]>ans then ans:=f[i];
end;
writeln(ans);
end;
end.
各位大佬,这题为什么错了??
0
已采纳
这是我写的,从后往前推。
readln(n);
for i:=1 to n do
read(a[i]);
readln;
f[n]:=1;
for i:=n-1 downto 1 do
begin
s:=1;
for j:=i+1 to n do
if(a[j]>a[i])and(f[j]+1>=s) then s:=f[j]+1;
f[i]:=s;
end;
s:=0;
for i:=1 to n do
if f[i]>s then s:=f[i];
writeln(s);
0
0
0
0
0



