You are on the right track. The problem is solved using a modified coin replacement algorithm: instead of requiring an exact solution, you will find one that reaches the highest total amount that does not exceed the target amount. Of course, if you find a solution whose deficit is less than any remaining set element, you stop it and report the solution.
When you find a solution, remove the βusedβ weights and repeat them until you select them. The number of iterations is the number of elevators you need.
If you sort the items in descending order, this gives you a greedy start with a retreat. I suspect this is close enough to optimal for many cases, especially if you memoize the results so that you don't repeat the errors in the next iteration.
You can try some pathological cases, such as the limit of 100, and extreme weights, such as
[93, 91, ..., 5, 4, 4]
The "greedy" algorithm first goes to 93 + 5, but later settles to 91 + 4 + 4 (a closer solution). This is where memoization comes in handy.
Will this lead you to a decision?
Prune source share