백준 :: ATM <11399번>

혜 콩·2021년 5월 18일
0

알고리즘

목록 보기
4/61

> 문제 <

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

> 아이디어 <

using 그리디 알고리즘
리스트 P(i)를 오름차순으로 정렬
P[1] + P[1]+P[2] + P[1]+P[2]+P[3] + P[1] ... (반복)
---> 이중 FOR문 사용

> 코드 (MINE) <

n = int(input())
p = sorted(list(map(int,input().split())))
t=0
for i in range(n):
  for j in range(i+1):
    t += p[j]
    
# cnt=0
# for i in range(n):
# 	cnt += p[i]
#  	t += cnt
# 이중 for문 대체 ( 시간 절약 )

print(t)

profile
배우고 싶은게 많은 개발자📚

0개의 댓글