c++ - How to divide a set into K subsets such that the sum of the elements in the subsets are minimal? -


i'm studying dp , problem came me when reading balanced partition algorithm. in algorithm can divide list in 2 lists such sum of elements of these lists equal. if need k lists , need them have minimal sum? thought of modifying balanced partition algorithm solve this, couldn't see way this.

let s {1,1,5}, optimal solution k = 2 {1,1}, {5}.

any hints? in advance.

a simple algorithm be:

sort s in descending order each element in s:     put partition smallest sum 

this put 5 first partition , 1s second partition in example (k=2).


Comments