Skip to content

Commit d2a5242

Browse files
committed
92차 3번 문제풀이
1 parent 2d14b33 commit d2a5242

1 file changed

Lines changed: 22 additions & 0 deletions

File tree

live9/test92/문제3/백유진.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import heapq
2+
3+
def solution(book_time):
4+
reservations = []
5+
for start, end in book_time:
6+
h, m = map(int, start.split(":"))
7+
start_min = h * 60 + m
8+
h, m = map(int, end.split(":"))
9+
end_min = h * 60 + m + 10 # 청소 시간 포함
10+
reservations.append((start_min, end_min))
11+
reservations.sort()
12+
13+
rooms = []
14+
15+
for start, end in reservations:
16+
if rooms and rooms[0] <= start:
17+
# 기존 방 사용 가능
18+
heapq.heappop(rooms)
19+
# 새 방 배정 (또는 기존 방 갱신)
20+
heapq.heappush(rooms, end)
21+
22+
return len(rooms)

0 commit comments

Comments
 (0)