Every box has at least no balls and at most N balls. Of course the total number of balls in M boxes must equal to N.
For each allocation, I calculated a value based on the allocation:
V=f(n_1,n_2,...n_m). I want to find out the maximum of V given N,M and f. I need to store the maximum V and the corresponding allocation results.
Using loops the complexity should be O(N^M), but loop isn't the way to go in this case.
Any hint or suggestion is greatly appreciated. Having few classical DP algorithm at hand but no luck.
f = f1 + f2 + ... f_m, where f(i)'s are polynomials. f(i) only depends on n(i).