We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 62bae88 commit 34263a9Copy full SHA for 34263a9
1 file changed
live11/test118/문제1/박희경.py
@@ -0,0 +1,18 @@
1
+import sys
2
+import heapq
3
+
4
+input = sys.stdin.readline
5
6
+t = int(input())
7
+for _ in range(t):
8
+ k = int(input())
9
+ file_size = list(map(int, input().split()))
10
+ heapq.heapify(file_size)
11
12
+ res = 0
13
+ while len(file_size) > 1:
14
+ cost = heapq.heappop(file_size) + heapq.heappop(file_size)
15
+ res += cost
16
+ heapq.heappush(file_size, cost)
17
+ print(res)
18
0 commit comments