PRATA question doubt


This question was explained in the course but I am unable to get the answer. Please help!!

My code runs correct for the test cases but does not get accepted in spoj.

Please explain me where I am doing wrong.
I got this in the divide and conquer section of coding blocks