不是VIP会员,不能显示答案

题目解答

题目:
const SIZE = 100;
var
n, ans, i, j : integer;
height, num : array[1..SIZE] of integer;
begin read(n);
for i := 1 to n do begin
read(height[i]);
num[i] := 1;
for j := 1 to i-1 do begin
if ((height[j] < height[i]) and (num[j] >= num[i])) then
num[i] := num[j]+1;
end;
end;
ans := 0;
for i := 1 to n do begin
if (num[i] > ans) then
ans := num[i];
end;
writeln(ans);
end.
输入:
8
3 2 5 11 12 7 4 10
输出:4
考点: 0
分析:
解答: 最长上升子序列的长度
评论:
老师: 0