사용자 도구

사이트 도구


ps:problems:boj:3745

오름세

ps
링크acmicpc.net/…
출처BOJ
문제 번호3745
문제명오름세
레벨골드 2
분류

LIS

시간복잡도O(nlogn)
인풋사이즈n<=100,000
사용한 언어Python
제출기록44308KB / 140ms
최고기록124ms
해결날짜2022/06/29
태그

[라이]세그먼트 트리

풀이

코드

"""Solution code for "BOJ 3745. 오름세".

- Problem link: https://www.acmicpc.net/problem/3745
- Solution link: http://www.teferi.net/ps/problems/boj/3745

Tags: [Longest increasing sequence]
"""

import bisect


def lis_length(seq):
    arr = [seq[0]]
    for val in seq:
        if val > arr[-1]:
            arr.append(val)
        else:
            arr[bisect.bisect_left(arr, val)] = val
    return len(arr)


def main():
    while True:
        try:
            N = int(input())  # pylint: disable=unused-variable
            nums = [int(x) for x in input().split()]
        except EOFError:
            break
        print(lis_length(nums))


if __name__ == '__main__':
    main()

토론

댓글을 입력하세요:
W Y S V P
 
ps/problems/boj/3745.txt · 마지막으로 수정됨: 2022/07/08 02:12 저자 teferi