problem with the code in c++



i have done the chefmover problem with c++ but it is showing WA for one testcase .but when i submiit the same concept in python i got 100 points.can anybody find where i am missing.
my c++ code
my python code


I think this must be because of overflow. Because it is given that range of Array A is 10^9 but you are taking the input of array in “int”.

int arr[n]; // from your code.

Since python doesn’t overflow easily, that can be one of possible reason.

Hope this helps!


got it .thank you


your welcome brother, please accept the solution if you think it helped!


yeah it got accepted after changing all variables to long long int


@manaranjanfav Sandeep meant that you mark his response as the answer to this question. You can hover onto this answer, you should see the accept answer option,


sorry i accepted the answer