Why am I getting TLE in this SPOJ problem?

help
binary-search
sparse-tables
spoj

#1

Hi there, I am trying to solve this problem with sparse table, I am getting TLE on this problem.

Here is what I tried.

Thanks in advance.


#2

Anyone on this?