Link to my submission CodeChef: Practical coding for everyone

It is based on priority queue

The priority queue approach is fine. But how to solve it using binary search. I tried but it gives me TLE.

You could binary search on the minimal x such that at least q_i numbers are less than or equal to x. Thatâs a bit more complicated and requires something like two pointers (or a second binary search), but you can try it if you want

Thanks for replying! I tried exactly as you said, also referred the second approach mentioned in this official editorial. I have used binary search to find minimal *x* and then two pointers. My Solution; would be great if you can please see it. Maybe the time limit is too strict.

Yeah, actually, reading the constraints, it seems like it would be really hard to make that pass. I think youâve written it right though - as far as I know, thatâs the best binary search solution you could use.

Thanks !