practivceAlgorithm/백준

[백준][Python] 1374 강의실

findTheValue 2021. 10. 16. 22:55

강의실 배정문제. 여러번 풀었던 문제.

방을 몇개 가져갈꺼냐?

끝난시간이면 빼고 갈아끼워준다.

 

import sys
input = sys.stdin.readline
from heapq import heappop, heappush

n = int(input())

heap = []
count = 0
for _ in range(n):
    num, start, end = map(int, input().split())
    heappush(heap, [start,end,num])

classroom = []
start, end, num = heappop(heap)
heappush(classroom, end)
while heap:
    start, end, num = heappop(heap)
    if classroom[0] <= start:
        heappop(classroom)
    heappush(classroom, end)
print(len(classroom))