D: Wood Cutting
https://open.kattis.com/problems/woodcutting
Last updated
https://open.kattis.com/problems/woodcutting
Last updated
First, there is no reason to cut some of a customer's wood pieces without cutting all of them - this will delay all customers' wait times without any benefit of completing a customer's pieces. So, for each customer we only need to consider the sum of all piece sizes (since we will cut all pieces together)
Next, minimizing average wait time is equivalent to minimizing total wait time, because the number of customers is a constant.
Finally, to minimize total time, sort the customer sums and cut wood pieces from the customer with smallest to largest sum. This is the same reason you do the easiest problems first on a programming contest to minimize total time penalty :)
After summing by customers and sorting, sum up the wait times for the total time, then divide by N to get the average wait time.