题解 | #Redraiment的走法# 贪心 + 二分法
Redraiment的走法
https://www.nowcoder.com/practice/24e6243b9f0446b081b1d6d32f2aa3aa
n = int(input())
nums = list(map(int, input().split()))
#贪心
res = []
for num in nums:
if not res or res[-1] < num:
res.append(num)
#大于 则替换
l,r = 0,len(res)#找到要替换的数
while l < r:
mid = (l+r) // 2
if res[mid] >= num:
r = mid
else:l = mid + 1
if r == len(res):res.append(num)
else:res[r] = num
print(len(res))