Https://ide.codingblocks.com/s/387823

plz help acc to me the strategy is correct but its not running in all cases .

Hello @asinghal1_be19 could you please discuss your strategy here.

The code which you have shared they are taking just the sum in that.
how this strategy is fine?

in any case i have to pick the even elements (element at the even index) as odd elements would be picked by the other one .

2 test cases ran plz tell me the test cases failed if u r unable to understand my approach

Hello @asinghal1_be19 no your strategy is completely wrong.
where it is written that you have to take even and odd elements?
it is not written anywhere.
both the players are playing optimally you have to think accordingly.
the case is just like that there can be many any number in range and piyush and nimit both plays optimally.

and we want piyuhs to win so we have to minimise the result of nimit.
you have to think of future and then minimise the result of the nimit.
have you done with the recursion?

no i m unable to proceed could u provide me the remaining 2 test cases so that i could understand or else plz provide me with some code on which i could proceed as u r unable to understand my strategy

may be i m thinking wrong plz tell a test case where my logic is failing

we dont have to minimise the value for nimit for that particular value but we have to minimise the overall result.
like in the sample test case when piyush picks up the max element i.e 4 then you nimit will pick up 3 as he is also playing optimally .
by optimally we mean that every turn of nimit will try to maximise his result.
let us take the example of the test case .
10
22 50 16 13 8 41 25 43 8 7
in this the piyush chooses number are 7+50+13+41+43
and nimit chooses number are 22+16+8+25+8.
and the output for piyush will be 154.
i hope i have cleared your doubt .
Happy Learning !!

https://ide.codingblocks.com/s/388567 plz check now

i m getting segmentation fault

@asinghal1_be19 some questions have particular technique to solve the question.
please see this code:
and then dry run the case which i gave you in the abive reply.


if you still have any doubt you can ask here:
HappyLearning!!

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.