Skip to content

Commit a8e1c98

Browse files
committed
[BOJ] 11000 강의실 배정 (G4)
1 parent 17edf9b commit a8e1c98

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

최어진/11주차/260313.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# 백준 11000번: 강의실 배정
2+
3+
import heapq
4+
import sys
5+
6+
input = sys.stdin.readline
7+
8+
# N <= 2 * 10^5
9+
N = int(input())
10+
11+
# 0 <= start, end <= 10^9
12+
classes = [list(map(int, input().rstrip().split())) for _ in range(N)]
13+
classes.sort()
14+
15+
# 기억나는 것들
16+
# - 이 유형의 그리디에서는 최소 힙에 시작 시간인지 종료 시간 중 하나만 쭉 넣었던 걸로 기억함
17+
runnings = []
18+
19+
answer = 0
20+
for start, end in classes:
21+
if runnings and runnings[0] <= start:
22+
heapq.heappop(runnings)
23+
heapq.heappush(runnings, end)
24+
25+
answer = max(answer, len(runnings))
26+
27+
print(answer)

0 commit comments

Comments
 (0)