004 컴퓨터과학/알고리즘
[백준 온라인저지] 정렬 알고리즘 / 11399. ATM
Dallas
2023. 6. 3. 15:14
반응형
문제
입출력
소스코드 1
시간 : 92ms
n = int(input())
times = list(map(int, input().split()))
times.sort()
answer = 0
for x in range(n) :
for j in range(x+1) :
answer += times[j]
print(answer)
소스코드 2
시간 : 40ms
n = int(input())
times = list(map(int, input().split()))
sum = 0
current = 0
times.sort()
for time in times :
current += time
sum += current
print(sum)
반응형