We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 8d642eb commit 41b489bCopy full SHA for 41b489b
1 file changed
live9/test92/문제1/박희경.py
@@ -0,0 +1,21 @@
1
+import heapq
2
+
3
+def solution(scoville, K):
4
+ answer = 0
5
+ heap = []
6
+ for s in scoville:
7
+ heapq.heappush(heap, s)
8
9
+ res = 0
10
+ while True:
11
+ min_value = heapq.heappop(heap)
12
+ if len(heap) == 0 and min_value < K:
13
+ return -1
14
+ if min_value < K:
15
+ res = min_value + (heapq.heappop(heap) * 2)
16
+ heapq.heappush(heap, res)
17
+ answer += 1
18
+ else:
19
+ break
20
21
+ return answer
0 commit comments