implement knapsack