Unfortunately I am getting wrong answer in all Test cases

Please help me to clear this problem. I was not able t get what is wrong with my solution. I tried a lot but again and again the wrong answer please review it if possible, or provide any test case where it is getting wrong. I wanted to do this with binary search.
Later I am able to solve subtask 1 but getting TLE but I had used binary search please help.


I solved it using another way but i am not getting what is wrong in it please help I wanted to do this using binary search.

Correct SOlution: https://www.codechef.com/viewsolution/39286529
Thanks in ADvance.

In your code you use :


Initially sum is 0. So it will break in first step.

Thanks for ur review i forgot to update new solution so by confusion i uploaded that now i edit that and success in getting subtask 1 but not able to know why TLE in second also I used Binary search. Thanks