牛客华为机试HJ103
作者:互联网
1. 问题描述
2. Solution
1、思路
2、代码实现
import sys
if sys.platform != "linux":
file_in = open("input/HJ103.txt")
sys.stdin = file_in
def solve(nums, n):
dp = [1] * n
for i in reversed(range(n)): # 4, 3, 2, 1, 0
for j in range(i + 1, n):
if nums[j] > nums[i]: # is increasing seq
dp[i] = max(dp[i], dp[j] + 1)
print(max(dp))
while True:
try:
n = int(input().strip())
nums = list(map(int, input().strip().split()))
solve(nums, n)
except:
break
3. 拓展
最长不下降子序列(LIS)问题,详细说明见 算法笔记 11.3
标签:nums,int,HJ103,strip,sys,牛客,机试,input,dp 来源: https://www.cnblogs.com/junstat/p/16181412.html