Skip to content

Instantly share code, notes, and snippets.

@maehrm
Created March 24, 2026 08:54
Show Gist options
  • Select an option

  • Save maehrm/4d70dc4f5eed8a3312c2dc938572e68d to your computer and use it in GitHub Desktop.

Select an option

Save maehrm/4d70dc4f5eed8a3312c2dc938572e68d to your computer and use it in GitHub Desktop.
import bisect
N = int(input())
A = [int(input()) for _ in range(N)][::-1]
lis = []
for i in range(N):
idx = bisect.bisect_right(lis, A[i])
if idx == len(lis):
lis.append(A[i])
else:
lis[idx] = A[i]
print(len(lis))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment