Solve knapsack problem using top down optimization