자료구조&알고리즘/백준

백준 | [파이썬 Python] 11399 ATM

두잇 두두 2024. 5. 18. 17:35
728x90

배경

https://www.acmicpc.net/problem/11399

 

 

코드

import sys
input = sys.stdin.readline
n = int(input())
peoples = list(map(int, input().split()))
peoples.sort()
result = 0
now_time = 0
for people in peoples:
    result += people + now_time
    now_time += people
print(result)

 

 

설명

앞선 회의실 문제와 비슷하지만 더 쉬운 문제이다

현재 시간은 계속 가니까 더 빨리 인출 할 수 있는 사람을 기준으로 정렬시킨다.

그리고 총 걸린 시간에 현재 시간을 더해준다

 

 

배운 점