TLE with recursion in http://www.codechef.com/problems/CIRCUITS/

I applied binary search with a recursive checking routine,But i keep getting tle with that.But when i applied iterative checking function i got accepted.