Problem link
Firstly, we must find the value of and it can easily proven that is less than or equal to , so we can iterate over all possible value of from to and calculate the cost of making all the sticks almost good for that .
That works in .
A solution in c++


0 Comments
If you have any doubts, Please let me know