Problem in hostel visit question


code is running fine for test cases but giving WA when submitted.
P.S. I have used priority queue for storing atmost k elements.

Note: We need to keep elements that you pop, so passing by value is a good option.
Please have a look at this short snippet.

sir actually that approach is giving TLE since q,x,y are all 10^6

I made a priority queue of atmost K elements so that removal is only O(1) task …but its giving me wrong ans in one test case…can you please provide me a reason why so?

Code I have attached passes l test cases for me. Why do think we get wrong anywhere?