문제의 상황에서도 알 수 있듯이, 1개의 회의실에 회의가 겹치지 않게 배정하기 위해서는 먼저 회의시간이 적은 회의들을 위주로 봐야되겠다고 생각할 수 있다. (회의시간이 적은 것들이 많을수록 회의의 개수는 커지기 때문)
하지만 회의시간이 적다고 해서 그 회의들이 이어져 있는 것이 아니므로 문제의 조건에 부합되기 위해서는 회의종료시간에 따라 정렬해야 되고, 조건에 따라 분류하여 해결해야 됨을 알 수 있다.
# 회의실 배정
from queue import PriorityQueue
import sys
input = sys.stdin.readline
N = int(input())
que = PriorityQueue()
before = 0
meetings = 0
for _ in range(N):
start, end = map(int, input().split())
que.put((end, start))
while not que.empty():
end, start = que.get()
if end > before and start >= before:
before = end
meetings += 1
elif end == before and start == end:
before = end
meetings += 1
print(meetings)