Hostel Visit Problem

how to sort the heap?

Hey @RULEREMPIRES
In this Question
Use MAx Heap

all testcases failed

and why we are using max heap instead of min heap?

@RULEREMPIRES
we will check if the current element is smaller than the root of the heap or not. If it is not smaller then we ignore it else we remove the root of the heap and push the new element in the heap.

@RULEREMPIRES
you are doing wrong
For every query of type 1, insert elements until the size of the heap becomes ‘k’.
Then for every query of type 1 after reaching the size k for heap(max-heap) we will check if the current element is smaller than the root of the heap or not. If it is not smaller then we ignore it else we remove the root of the heap and push the new element in the heap. (What this will do is maintain a heap of size k which will contain k nearest coordinates for the dean) .