11399: ATM

ewillwin·2023년 6월 16일
0

Problem Solving (BOJ)

목록 보기
74/230

  • 그리디 알고리즘을 쓰는 경우 -> 지역의 최적성이 최종 최적성을 보장할 때

import sys
from collections import deque

N = int(input())
person_time = list(map(int, sys.stdin.readline()[:-1].split()))
person_time.sort()

result = [0 for _ in range(N)]
for i in range(1, N + 1):
	result.append(sum(person_time[:i]))
print(sum(result))
profile
Software Engineer @ LG Electronics

0개의 댓글