https://school.programmers.co.kr/learn/courses/30/lessons/82612
def solution(price, money, count):
answer = 0
for i in range(1, count + 1):
answer += price * i
if answer - money > 0:
return answer - money
return 0
def solution(price, money, count):
return abs(min(money - sum([price*i for i in range(1,count+1)]),0))
내 답을 한 줄로 줄여놨다.
def solution(price, money, count):
return max(0,price*(count+1)*count//2-money)
등차수열의 합을 이용한 계산