Example 4: Knapsack problem