Skip to content

Commit 1bd2b87

Browse files
committed
92차 2번 문제 풀이 (푸는중)
1 parent 41b489b commit 1bd2b87

1 file changed

Lines changed: 29 additions & 0 deletions

File tree

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

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import heapq
2+
3+
def solution(book_time):
4+
answer = 0
5+
# book_time.sort()
6+
7+
def change_minute(time):
8+
h, m = map(int, time.split(":"))
9+
return h * 60 + m
10+
11+
heap = list([change_minute(start), change_minute(end) + 10] for start, end in book_time)
12+
# [[850, 1160], [860, 920], [900, 1020], [1000, 1100], [1100, 1280]]
13+
14+
heapq.heapify(heap)
15+
print(heap)
16+
17+
while heap:
18+
start, end = heap[0]
19+
print(heap)
20+
next_start, next_end = heapq.heappop(heap)
21+
if start <= next_start <= end:
22+
answer += 1
23+
start = next_start
24+
end = next_end
25+
else:
26+
break
27+
28+
29+
return answer

0 commit comments

Comments
 (0)