This a photo from IDE one that program succeeded to run
So what could be different between ideone and spoj… the test data.
Spoj is likely to test all sorts of odd conditions, including the max constraints.
I get runtime error on spoj that there is segmentation error but i didn’t find anything for that
Well spotted. I never occurred to me to look at the ideone URL from the screen shot.