TLE in SPOJ Problem RPLN

I am trying to solve SPOJ problem SPOJ.com - Problem RPLN

I am using a SegTree approach, (O(N), O(lgN)) with printf and scanf but getting a TLE. I though Sparse table approach should be used but same approach gets AC.

The test cases got updated and the status got updated, so I even tried old submissions now in the same approach , but they are getting AC.

For eg., Getting TLE in RPLN Spoj uses the same approach.

This is my code. what am i missing here?