Minimum cost to cut stick
Your task
You have a wooden stick of length n marked from 0 to n. You must perform all the cuts at the positions listed in cuts, in any order you choose. The cost of one cut equals the current length of the stick piece being cut, and after a cut the piece splits into two. Return the minimum total cost to perform every cut. Here 2 <= n <= 10^6 and cuts has at most 100 distinct positions strictly between 0 and n.
Examples
min_cost_cut_stick(n: int, cuts: list[int]) -> intExample 1
Input
min_cost_cut_stick(7, [1, 3, 4, 5])Output
16