https://ide.codingblocks.com/s/258889, I am using heap even then getting TLE, any way to optimize the code?
Heap - Hotel Visit, TLE
hello @rohit267
you are getting tle becuase u are using min heap.
for each query of type two u will pop k elements so in worst case for q such query u will be performing q*k operations which will give tle.
use max heap to answer this query efficiently.
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) .
For every query of type 2 just print the root of the heap.
I did what you told, modified the code

use >=
also
use long long method in place of int