| ps | |
|---|---|
| 링크 | acmicpc.net/… | 
| 출처 | BOJ | 
| 문제 번호 | 12015 | 
| 문제명 | 가장 긴 증가하는 부분 수열 2 | 
| 레벨 | 골드 2 | 
| 분류 | 
 LIS  | 
	
| 시간복잡도 | O(nlogn) | 
| 인풋사이즈 | n<=1,000,000 | 
| 사용한 언어 | Python | 
| 제출기록 | 155552KB / 1056ms | 
| 최고기록 | 844ms | 
| 해결날짜 | 2021/06/15 | 
| 태그 | |
"""Solution code for "BOJ 12015. 가장 긴 증가하는 부분 수열 2".
- Problem link: https://www.acmicpc.net/problem/12015
- Solution link: http://www.teferi.net/ps/problems/boj/12015
Tags: [LIS] [BinarySearch]
"""
import bisect
def main():
    N = int(input())  # pylint: disable=unused-variable
    A = [int(x) for x in input().split()]
    arr = []
    for a_i in A:
        pos = bisect.bisect_left(arr, a_i)
        if pos == len(arr):
            arr.append(a_i)
        else:
            arr[pos] = a_i
    print(len(arr))
if __name__ == '__main__':
    main()