knapsack with dynamic combinations