八十分求调!!

B3637 最长上升子序列

JamesLu @ 2024-03-24 12:13:07

n = int(input())
a = [0] + list(map(int, input().split()))
dp = [0] * (n + 1)  # dp[i]是以第i个数结尾的序列长度
dp[1] = 1
for i in range(1, n + 1):
    for j in range(1, i):
        if a[j] < a[i]:
            dp[i] = max(dp[i], dp[j] + 1)
    if dp[i] == 0: dp[i] = 1
print(max(dp))

|