import Foundation
func solution(_ price:Int, _ money:Int, _ count:Int) -> Int64{
var answer:Int64 = 0
for i in 1...count {
answer += Int64(i * price)
}
if answer - Int64(money) <= 0 {
return 0
}
return answer - Int64(money)
}
import Foundation
func solution(_ price:Int, _ money:Int, _ count:Int) -> Int64{
let totalPrice = price * (count * (count+1)/2)
if money >= totalPrice {
return 0
}
return Int64(totalPrice - money)
}