Can anybody explain the logic behind the lowest sum of contest 3 of dsa learning

Link to my submission CodeChef: Practical coding for everyone
It is based on priority queue

as i don’t know priorty queue I made it simple my submission

thanks buddy @galencolin

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

1 Like

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.

1 Like

Thanks !