Time exceeded solution for DevuLand, Dinosaurs and Laddus problem - http://www.codechef.com/OCT14/problems/PRLADDU