BOJ - 11000 - 강의실 배정
Updated:
import sys
import heapq
def solution():
cnt = 1
N = int(sys.stdin.readline())
pq, rooms = [], []
for _ in range(N):
[a, b] = [int(e) for e in sys.stdin.readline().split()]
heapq.heappush(pq, (a, b))
heapq.heappush(rooms, heapq.heappop(pq)[1])
while pq:
curr = heapq.heappop(pq)
if curr[0] < rooms[0]:
cnt += 1
else:
heapq.heappop(rooms)
heapq.heappush(rooms, curr[1])
print(cnt)
solution()
https://www.acmicpc.net/problem/11000
Leave a comment