I am using egg dropping puzzle approach to solve MAXEP problem.
I am not getting why I am getting WA . Here is my code : solution link.
N can be max 150000 & c (cost) can be max 150.
So according to egg dropping puzzle solution constraint (k*(k+1))/2 <= (N=150000), k can be max 548.
And for this approach panel can be broken only 2 times (why because first time panel will break it means we get segment [l,u] where u-l+1<=548 after that we will traverse left to right in segment [l,u] so after second time we will get exact answer we will print and exit).
So total cost = 548 + 2*150 = 848 in worst case.
According to my solution , we will always get answer x according to given constraints.
I am not sure why it is giving WA for few test cases.
In my solution, main culprit was this statement u=u+k-1;
So I have updated to this u=min(n,u+k-1) and maintaining previous state here is my working solution