문제 링크
풀이
import sys
n = int(sys.stdin.readline())
p = list(map(int, sys.stdin.readline().split()))
p.sort()
acc = 0
for i in range(n):
acc += sum(p[:i+1])
print(acc)
P1~Pn의 합이 최소가 되려면 P를 오름차순 정렬한 순서대로 돈을 인출하면 된다.
'연습장 > 백준(BOJ) 문제풀이' 카테고리의 다른 글
[백준 4949] 균형잡힌 세상 with Node.js (0) | 2021.04.17 |
---|---|
[백준 1764] 듣보잡 with Node.js (0) | 2021.04.16 |
[백준 1003] 피보나치 함수 with Python (0) | 2021.04.14 |
[백준 9095] 1, 2, 3 더하기 with Python (0) | 2021.04.14 |
[백준 1021] 회전하는 큐 with Node.js (0) | 2021.04.14 |