Hostel visit error

sir I am confused in this question how to proceed further. plzz help I am also getting an error but unable to sort it and I have tried this question with max heap
link:https://ide.codingblocks.com/s/117918

@khushi91200 You do not need to think much for this question. Also, sorting is not required here.
Make a rocket distance function that would take x coordinate and y coordinate as parameters and return rocket distance as given in the problem statement.
When query is of type 1, find the rocket distance and push it in the max heap of size k. When max heap is full and still the query is of type 1: then:
if (pq.size() == k){
if (rocketDistance(x,y) < pq.top() )
{ //It rocket distance at top of heap is greater than current rocket dist then pop it
pq.pop();
pq.push(rocketDistance(x,y));
}
}
When query is of type 2, print the rocket distance stored at top of the heap.

Hope this helps.

do we need to make class hostel or compare in this question???

No not required. Just make a rocketdistance function…you already have a minheap so sorting is not required.

sir minheap or maxheap ??
coz according to my logic we need a max heap

Yeah…sorry.you need a max heap
Try to implement it. Do let me know if you face any problem.

ok sir let me try it

for one test case my code is showing passed and for other it is showing wrong answer. link:https://ide.codingblocks.com/s/118030

The constraints may be large, so try with long long int and then check
Let me know if still test case does not pass

still giving wrong answer link:https://ide.codingblocks.com/s/118035

sir done now it is passed thanks sir