Colourful knapsack

Can you please provide me with the implementation of this question. I am struggling with it.

@aman_ishan hey ,here is code for your reference:
https://ide.codingblocks.com/s/110377?_ga=2.104557768.95256106.1584124297-1940767847.1534408565

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.