Algorithm/boj

[파이썬] 2565 전깃줄

takeU 2022. 6. 13. 15:25
반응형
from bisect import bisect_left

n = int(input())
li = sorted([list(map(int, input().split())) for _ in range(n)])
li = list(map(lambda x: x[1], li))
dp = []

for l in li:
    cur = bisect_left(dp, l)
    if len(dp) <= cur:
        dp.append(l)
    else:
        dp[cur] = l

print(len(li) - len(dp))

dp, LIS