2nd Testcase is giving TLE I HAVE USED long long int

Please tell why my code is giving tle and mention in comments in the program why my code was giving TLE

Here is my code : https://ide.codingblocks.com/s/268026

Use a max heap for this problem. Refer this Hostel Visit- TLE

If k is small then minnheap is sufficient suppose heap size is 1000 and I need 667 th nearest hostel then Maxheap will have less number of pop operations am I correct.Thats why we need to use Maxheap.

Yes…you are correct
If you are doing it by the maxheap approach, at any case maxm size of your heap will be k… so complexity will be O(nlogk)
Whereas with min heap…maxm size of your heap will be n…So complexity will be O(n log n)

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.