Can you tell why it is giving wrong answer for some test cases?

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

I am not getting what wrong is going in it
november challenge 2019 - Physical Exercise