LadderRide Dp Hackerearth

it is showing wrong ans as well as TLE in my code .plz tell me the problem in my code
The link is-
https://www.hackerearth.com/submission/25486270/