For this Problem It is mentioned in the problem statement that no one goes empty handed.
But for this test case
1
5 4 100
1 3 10
2 3 45
3 4 76
3 5 87
The best solution http://www.codechef.com/viewsolution/368201 gives the output
683
186 221 176 100 0
but according to me there should be no person going with 0 bonus. Our solution is http://www.codechef.com/viewsolution/5156561. Please check it!!!