Reduction in memory usage for dp knapsack