We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
2 parents f71b15a + 4ce8d9c commit 375d527Copy full SHA for 375d527
2 files 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
live11/test118/문제2/박희경.py
+n = int(input())
+cards = []
+for _ in range(n):
+ cards.append(int(input()))
+heapq.heapify(cards)
+total = 0
+while len(cards) > 1:
+ sum = heapq.heappop(cards) + heapq.heappop(cards)
+ total += sum
+ heapq.heappush(cards, sum)
+print(total)
0 commit comments