728x90
단계별로 풀어보기 그리디 알고리즘의 3단계 문제
운영체제에서도 배운 SJF(Shortest Job First)로 하면 기다리는 시간이 최소가 된다.
from sys import stdin
n = int(input())
time = list(map(int, stdin.readline().split()))
time.sort()
acc = [0] * n
acc[0] = time[0]
for i in range(1, n):
acc[i] = acc[i - 1] + time[i]
total = 0
for i in range(n):
total += acc[i]
print(total)
728x90
'알고리즘 문제' 카테고리의 다른 글
[백준] 1541번 잃어버린 괄호 (0) | 2020.01.10 |
---|---|
[백준] 1931번 회의실 배정 (0) | 2020.01.10 |
[백준] 11047 동전0 (0) | 2020.01.10 |
[백준] 1012 유기농 배추 (0) | 2020.01.08 |
[백준] 2667번 단지번호붙이기 (0) | 2020.01.08 |