Chef and time Machine

Problem :- CHEFTMA Problem - CodeChef

I am getting the wrong answer. Can anyone explain to me the reason and provide a test case where my solution is wrong.

https://www.codechef.com/viewsolution/28732066