About the logic of knapsack 2

pls help me out with the logic. I dont understand how to decide the state of dp seeing a qstn and also I didn’t understand the logic of the qstn.

Hello @Senjuti256 have you done the same question 0-1 knapsack?

Yes but how to decide the state of dp for the same qstn seeing the constraints?

@Senjuti256 i suggest you to first try the pure recursive solution of every DP question. then try to optimise by making the dp of that dimension the number of parameters in your recursion call.