0-n knapsack(hackers block)

can you tell me the approach of this code

https://hack.codingblocks.com/contests/c/917/922 – this is the url of the question in case.

@Ayushi21
I request you to kindly refer to this DP Webinar by Prateek Bhaiya

He discusses several DP Problems in this Webinar along with 0-1 Knapsack and 0-N Knapsack.

Jump to 2 hr 59 min 22 sec for 0-1 Knapsack
Also, he discusses the exact modification in 0-1 Knapsack to make it work for 0-N Knapsack
at 3 hr 47 min time.

Let me know if your doubt still persists after or if you are having trouble coding the problem and I will be happy to help you out.

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.