pop으로 풀어보려 했는데 당연히 시간초과,,^^ 가 떠서 구글링해보니까
sort와 pop을 같이 해야하면서 시간도 맞추려면 heapq 를 쓰면 된다고 합니당... 어려운 코테의 세계
단순무식한 for 문의 인간은 발전 중,,,
import sys
import heapq
n = int(sys.stdin.readline())
heap = []
for _ in range(n):
start, end = map(int,sys.stdin.readline().split())
'''
heapq:
(a, b) a가 작은 순으로 정렬하여 list 를 만들어줌
'''
heapq.heappush(heap, (end, start))
# 초기값
end_time = 0
# 강의 수
count = 0
while heap:
end, start = heapq.heappop(heap)
# 시작시간이 초기값(종료시간)보다 크거나 같으면 cnt+=1
if start >= end_time:
count += 1
end_time = end # 새로운 end time 으로 갱신
print(count)