getting RE need help finding bug

,

problem: https://www.codechef.com/problems/MAXDIST/
soln : https://www.codechef.com/viewsolution/10514264

//