Getting Wrong answer in all test cases

code

Hello @vg5823967,

ans = max(sum , ans);
This won’t work.

You have to keep in mind that both opponent and you are playing optimal.
What you are missing?
The opponent will chose a coin in such a way that you would can collect minimum money. (This is a big hint. Think about it.)

Calculating maximum ans won’t help.
You have consider that factor that opponent would choose something that you would get minimum.

Let me know if you still face any difficulty.
Hope, this would help.

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.