https://programmers.co.kr/learn/courses/30/lessons/82612
[실패]
public class Solution {
public long solution(int price, int money, int count) {
for (int i=0; i<count; i++) {
total_price += price * (i+1);
}
if (total_price >= money) {
return total_price - money;
} else {
return 0;
}
}
}
public class Solution {
public long solution(int price, int money, int count) {
long total_price = price * ((long)count * (1 + count) / 2);
if (total_price >= money) {
return total_price - money;
} else {
return 0;
}
}
}