Time exceeded solution for Chef and Frogs problem - http://www.codechef.com/JULY14/problems/FROGV/