题解 | #Redraiment的走法#
Redraiment的走法
http://www.nowcoder.com/practice/24e6243b9f0446b081b1d6d32f2aa3aa
def lenfirst(nums,i):
if i in memo.keys():
return memo[i]
if len(nums[i:]) == 1:
return 1
res = 1
for j in range(i+1,len(nums)):
if nums[i] < nums[j]:
res = max(res, lenfirst(nums, j) + 1)
memo[i] = res
return res
def lentotal(nums):
return max(lenfirst(nums, i) for i in range(len(nums)))
while True:
try:
a = input()
b = list(map(int,input().split()))
memo = {}
print(lentotal(b))
except:
break