dynamic programming solves knapsack problem