this is ,y code. should i use heap sort or is my approach correct
Segmentation fault
@tanjuljain19
Declare your priority queue outside while(t–) loop
just cut line 15 and paste after line no. 10
@tanjuljain19
Your code is giving TLE because you are first poping k element form your min priority queue and then again inert them to priority queue, this will make your code more complex. So what you can do is, maintain a max priority queue and you query of type 2 pop elements from queue untill it’s size become equal to k.
Also use long long int
here is the modified code : https://ide.codingblocks.com/s/239543
I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.
On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.