Given:
-A set of items that each have costs for being placed into a given container type.
-A set of container types that each have a number of available containers.
Example:
Amount*Container-Type : 5 * A, 3 * B, 2 * C
Items(Costs) :
3 * X (A=2, B=3, C=1)
2 * Y (A=5, B=2, C=2)
1 * Z (A=3, B=3, C=1)
Problem:
Find the best placement of the items into the containers so that the costs are minimal. For simplicity, only place an item into a single type of container.
I tried the hungarian method to solve the problem, but with a runtime of O(n³), it's quite prohibitive for large problems (e.g., 100000 items).
My current solution is a greedy approach, that just orders the item-container combinations by costs (asc) and assigns the first container with a sufficient amount left in O(n log n).
Is there a better solution?