BOJ
-
[BOJ 9881] Ski Course DesignProblem Solving 2023. 10. 15. 13:31
N(>= 1, > n; std::cin.ignore(); std::vector hills(n); for (int i = 0; i > hills[i]; std::cin.ignore(); } std::sort(hills.begin(), hills.end()); int minCost, tempCost, idx, diff, maxInRange; minCost = std::numeric_limits::max(); for (int minInRange = hills[0]; minInRange maxInRange) { diff = maxInRange - hills[idx]; tempCost += diff * diff; idx--; } if (tempCost < minCost) {..