imperative knapsack