I am Getting tle but i think i am not breaking constraints

Below is my Code

TLE on second case in HOTEL VISIT problem

you are taking k*log(n) time for every query optimize it to log(n)

but if i will not use k then how will i pop the kth nearest hotel

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.

#include <iostream>
#include <queue>
#define ll long long int
using namespace std;

ll rocketDistance(ll x, ll y) {
    return x*x + y*y;
}
int main(int argc, char const *argv[])
{
    int q, k, x, y, type;
    cin>>q>>k;
    priority_queue<ll> pq;
    for(ll i=0;i<q;i++) {
        cin>>type;
        if(type==1) {
            cin>>x>>y;
            if(pq.size()==k) {
                if(rocketDistance(x, y)<pq.top()) {
                    pq.pop();
                    pq.push(rocketDistance(x, y));
                }
            } else {
                pq.push(rocketDistance(x, y));
            }
        } else {
            cout<<pq.top()<<endl;
        }
    }
    return 0;
}

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.