题解 | 最长上升子序列(一)
import sys n = input() n = int(n) a = list(map(int, input().split())) dp = [1 for i in range(n + 100)] for i in range(1, n): for j in range(i): if a[i] > a[j]: dp[i] = max(dp[i], dp[j] + 1) print(max(dp))
dpdp
import sys n = input() n = int(n) a = list(map(int, input().split())) dp = [1 for i in range(n + 100)] for i in range(1, n): for j in range(i): if a[i] > a[j]: dp[i] = max(dp[i], dp[j] + 1) print(max(dp))
dpdp
相关推荐