fork download
  1. pole = [int(_) for _ in input().split()]
  2. S = []
  3.  
  4. for x in pole:
  5. # i = 0
  6. # while i < len(S) and S[i] < x:
  7. # i += 1
  8. l,r = 0, len(S)
  9. while (l < r):
  10. s = (l+r)//2
  11. if S[s] < x:
  12. l = s+1
  13. else:
  14. r = s
  15. if l == len(S):
  16. S.append(x)
  17. else:
  18. S[l] = x
  19. print(1+l)
  20.  
Success #stdin #stdout 0.01s 27712KB
stdin
2 6 3 4 1 2 9 5 8
stdout
1
2
2
3
1
2
4
4
5