Skip to content

Commit 4ce8d9c

Browse files
committed
118차 2번 문제풀이
1 parent 34263a9 commit 4ce8d9c

1 file changed

Lines changed: 18 additions & 0 deletions

File tree

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import sys
2+
import heapq
3+
4+
input = sys.stdin.readline
5+
6+
n = int(input())
7+
cards = []
8+
for _ in range(n):
9+
cards.append(int(input()))
10+
11+
heapq.heapify(cards)
12+
total = 0
13+
while len(cards) > 1:
14+
sum = heapq.heappop(cards) + heapq.heappop(cards)
15+
total += sum
16+
heapq.heappush(cards, sum)
17+
18+
print(total)

0 commit comments

Comments
 (0)