I think its some variant of 01 knapsack problem. But I cant figure out the solution? anybody have any idea? any deal will help.

https://brainly.in/question/33854691#:~:text=Explanation%3A,maximum%20possible%20energy%20is%209.

I am not sure but i think we need to have one extra state to know how many BluesLtd products have been covered until now i.e

dp will be

dp[i][j][0] - max total energy value if we consider only 1st i values and having weight j and we haven’t taken any BluesLtd(which represents 0).

dp[i][j][1] - max total energy value if we consider only 1st i values and having weight j and we have taken exactly one BluesLtd(which represents 1).

dp[i][j][2] - max total energy value if we consider only 1st i values and having weight j and we have taken more than one BluesLtd(which represents 2).

This is the basic idea.

This question is a variation of 0/1 Knapsack

If I write the solution to this question It will pass your all test case

**except** In that case when my code selects only one Blue.

But still, I am trying to solve the question completely If I solved your question I will send the link of my code.