Comments

but I found cases where we could add y and use x everyday and it would be possible and still be in range. But if we follow this algorithm it says no. case is k=999984 le=1 r=1999966 t=999984 x=999983 y=999984 After first day we will have k=1 and after that we will just add y and use x and it is possible to remain in range. then why is your code optimal ?Because this case has a possible case but says wrong!

in PROBLEM:E: do we have to minimize the number of times we add y? because the solution says we will lower the level as many time as we can ,but why can't we add y as many times as we can.