the question I have a problem is as follows:
Given a queue of N items, each with a weight, and the queue of K containers. And we need to partition the items to the containers in the order they came. For example, the very first item can only go to the first container, the second one can go to either the first or the second but not the third (otherwise the second container won't have any items).
I need to create and implement an algorithm that make some kind of uniform distribution, so the heaviest container must be as lightweight as it can; to give count of containers with such weight.
I suppose it is some variation of 3-partition or knapsack problem. I have already implemented one possible solution for distribution using dynamic programming and tried to get count from the table used in it. But it was not effective enough (too much memory expensive), and algorithm of getting the amount of containers wasn't correct.
Can someone explain, please, which algorithm is solution for this problem?