DBOY-wrong ans

Someone please tell ,what is the problem in the logic of the following code :
http://www.codechef.com/viewsolution/3499725

or please provide me with some test case where my code fails.

problem link : DBOY Problem - CodeChef