PLEASE CHECK THE CODE ITS GIVING SEGMENTATION FAULT

Check now ->


Have just improvised your code.

WHAT WERE THE CHANGESYOU MADE…ALSO WHY HAVE YOU DECLARED p[] ans csum[] ARRAYS GLOBALLY

That’s because declaring a container of size 10^5 multiple times will led to TLE or even segmentation Fault, so have declared them as globally. In line 17 value of j is int. It should be long long int to avoid overflow as j will calculate (10^5)^2 so these changes have been applied.

OKIE THANKYOU SO MUCH:)

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.