knapsack problem
rename dp() to be simply f()