Successful solution for Chef and Ground problem - http://www.codechef.com/OCT14/problems/CHEFGR