Skip to content

Commit 1cdfc45

Browse files
committed
94차 2번 문제 풀이
1 parent 9f63f9c commit 1cdfc45

1 file changed

Lines changed: 19 additions & 0 deletions

File tree

live9/test94/문제2/박희경.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import heapq
2+
3+
def time_to_minute(time):
4+
h, m = map(int, time.split(':'))
5+
return h * 60 + m
6+
7+
def solution(book_time):
8+
9+
book = sorted([[time_to_minute(start), time_to_minute(end) + 10] for start, end in book_time])
10+
11+
room = []
12+
for start, end in book:
13+
if room:
14+
early_end = room[0] # 가장 빠른 퇴실 시간
15+
if start >= early_end: # 입실 시간이 가장 빠른 퇴실 시간 이후라면 갱신
16+
heapq.heappop(room)
17+
heapq.heappush(room, end)
18+
19+
return len(room)

0 commit comments

Comments
 (0)