백준 문제
ATM-11399 (python)
우제혁
2019. 12. 27. 16:11
처음 접근한 방법(틀린 이유를 모르겠음)
time= []
times=[]
sum=0
sum_=0
people=int(input(''))
time= input().split()
time_ = sorted(time)
for i in time_:
sum=sum+int(i)
times.append(sum)
for i in range(0,people):
sum_+=times[i]
print(sum_)
+map
map(함수, <literable object>)
->함수를 각 객체에 적용시켜줌
응용한 최종 답
time= []
times=[]
sum=0
people=int(input(''))
time= map(int,input().split())
time_ = sorted(time)
for i in range(0,people):
sum+=time_[i]*(people-i)
print(sum)