사용자 도구

사이트 도구


ps:problems:boj:12015

가장 긴 증가하는 부분 수열 2

ps
링크acmicpc.net/…
출처BOJ
문제 번호12015
문제명가장 긴 증가하는 부분 수열 2
레벨골드 2
분류

LIS

시간복잡도O(nlogn)
인풋사이즈n<=1,000,000
사용한 언어Python
제출기록155552KB / 1056ms
최고기록844ms
해결날짜2021/06/15
태그

[단계별]21단계, [라이]세그먼트 트리

풀이

코드

"""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()

토론

댓글을 입력하세요:
T​ I A S T
 
ps/problems/boj/12015.txt · 마지막으로 수정됨: 2022/07/08 01:50 저자 teferi