반응형
문제
입출력
소스코드 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)
반응형
'004 컴퓨터과학 > 알고리즘' 카테고리의 다른 글
[백준 온라인저지] 정렬 알고리즘 / 2587. 대표값2 (0) | 2023.06.03 |
---|---|
[백준 온라인저지] 정렬 알고리즘 / 1946. 신입 사원 (0) | 2023.06.03 |
[백준 온라인저지] 정렬 알고리즘 / 1920. 수 찾기 (0) | 2023.06.03 |
[백준 온라인저지] 정렬 알고리즘 / 10817. 세 수 (0) | 2023.06.03 |
[백준 온라인저지] 정렬 알고리즘 / 2750. 수 정렬하기 (0) | 2023.06.03 |
댓글