본문 바로가기

Algorithm/Python

[Algorithm|Python] 백준 19598번 / 99클럽 20일차 TIL

import sys
import heapq as hq

input = sys.stdin.readline
n = int(input())

times = []

for _ in range(n):
    times.append(list(map(int, input().split())))
    
times.sort(key=lambda x:x[0])

arr = [0]
count = 1

for start, end in times:
    if start >= arr[0]:
        hq.heappop(arr)
    else:
        count += 1
    hq.heappush(arr, end)

print(count)