사용자 도구

사이트 도구


ps:problems:boj:15015

Manhattan Mornings

ps
링크acmicpc.net/…
출처BOJ
문제 번호15015
문제명Manhattan Mornings
레벨플래티넘 5
분류

LIS

시간복잡도O(nlogn)
인풋사이즈n<=100,000
사용한 언어Python 3.13
제출기록50140KB / 196ms
최고기록196ms
해결날짜2026/01/12

풀이

코드

"""Solution code for "BOJ 15015. Manhattan Mornings".

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

Tags: [LIS]
"""

import sys
from teflib import seqtask


def main():
    n = int(sys.stdin.readline())
    xh, yh, xw, yw = [int(x) for x in sys.stdin.readline().split()]
    x0, y0, x1, y1 = (xh, yh, xw, yw) if xh < xw else (xw, yw, xh, yh)
    if y0 > y1:
        y0, y1 = -y0, -y1
    coords = []
    for _ in range(n):
        x_i, y_i = [int(x) for x in sys.stdin.readline().split()]
        if y0 < 0:
            y_i = -y_i
        if x0 <= x_i <= x1 and y0 <= y_i <= y1:
            coords.append((x_i, y_i))

    seq = [y for x, y in sorted(coords)]
    answer = seqtask.longest_inc_subseq_length(seq, strict=False)

    print(answer)


if __name__ == '__main__':
    main()

토론

댓글을 입력하세요:
X K H X Y
 
ps/problems/boj/15015.txt · 마지막으로 수정됨: 2026/01/12 14:47 저자 teferi