Algorithm/BOJ
[백준] 11000 강의실 배정 (파이썬 python)
YOONJELLY
2024. 2. 27. 12:18
문제 링크
https://www.acmicpc.net/problem/11000
11000번: 강의실 배정
첫 번째 줄에 N이 주어진다. (1 ≤ N ≤ 200,000) 이후 N개의 줄에 Si, Ti가 주어진다. (0 ≤ Si < Ti ≤ 109)
www.acmicpc.net
문제 풀이
import heapq
n = int(input())
times = []
for _ in range(n):
times.append(list(map(int, input().split())))
times.sort()
room = []
heapq.heappush(room, times[0][1])
for i in range(1, n):
if times[i][0] < room[0]:
heapq.heappush(room, times[i][1])
else:
heapq.heappop(room)
heapq.heappush(room, times[i][1])
print(len(room))