knapsack solver
optimized again