What wrong here

Why this code is showing run time error…although it perform well in custom input

run time errror is because of line no 13
you make size of step array =1000
but in constraints it is given size of array can be 2*10^5

use int no need to use long long int

also there is also one more mistake
at line not 13
int step[200000]={0};
if you use it then it will give TLE

simply use
int step[200000];

Modified Code

if you have more doubts regarding this feel free to ask
i hope this helps
if yes hit a like :heart:: and don’t forgot to mark doubt as resolved :grinning:

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.