[SPOJ] ANDROUND TLE
Problem statement is here and i am getting TLE for this solution. Looks O(31*N) to me, any idea(s) how to improve??