Rating:
The problem is just solving a straightforward knapsack problem. You may ignore most of the code.
I don't remember