I am getting tle in one test case pls help

@Vipul.kapoor take long long datatype for the distance calculated as x*x + y*y can be a very large value

i have defined int as long long in the starting of the code
so i think there should be no problem with data types

@Vipul.kapoor sorry i missed that line!
try not to add more than k elements in the heap in the first place, you can place a check for that while insrting.
suppose you have 1000 insertion queries. and k is given as 3 or some other small number

so for query == 2, you will have to remove all the unnecessary elements in almost linear time
that will increase the time complexity to almost quadratic (q queries, do this lengthy operation for each of them)

what you can do instead is
for query of type 1
there will be 2 cases, pq.size() < k and pq.size() >= k
for pq.size() you can insert any distance
for the other case, you can place a check there itself if the distance needs to be inserted in the heap or not. If you do insert an element, pop another element then and there itself. This was you can ensure that the size of heap will always be k only at the time of query of type 2

so for query of type 2, simply print the top element

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.