### myaw's blog

By myaw, history, 5 years ago,

I just solved this problem in uva.onlignejudge 10664 a classical dp problem ( you have n weights and you want to find a way to distribute these weights equally between 2 people ) so you only need a simple dp to find (total sum of weights ) / 2 using given weights .

but what if we decided to shares these weight between k people how to solve that ? do we have to keep track on the chosen weights ??

• +1

 » 5 years ago, # |   0 Solved the problem : http://lightoj.com/volume_showproblem.php?problem=1147 The problem is almost similar to your question . Thanks .
•  » » 5 years ago, # ^ |   0 obviously you didn't read my statement will , i was able to solve that problem for 2 people now i'am asking how we solve it for k people ??
 » 5 years ago, # | ← Rev. 4 →   0 You can do brute-force for O(kn) or dp for O(k^{2}*MAXSUM^{k — 1}).I dont think it's possible to solve it faster.
•  » » 5 years ago, # ^ |   0 can you give your dp approach ??
•  » » » 5 years ago, # ^ |   0 dp[i][val1][val2]...[val k -1] is it possible to distribute birst k items, so first have val1, second — val2 and so on. There are k * MAXSUM(k - 1) states and you need O(k) to do step, you simply choose who takes ith item.