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