Hotel visit - gives TLE , any hint to make it faster

int main() {

priority_queue<int,vector<int>,greater<int>>pq;
vector<int>v;

int n,k;
cin>>n>>k;
for(int i=1;i<=k;i++){
	int t;
	cin>>t;
	if(t==1){
		int a,b;
		cin>>a>>b;

     int dis=(a*a)+(b*b);
	
	 pq.push(dis);
	}
}
int queries_left=n-k;
while(queries_left--){
	
	int type;
	cin>>type;
	int temp[k-1];
		int i=0;
		int times=k-1;
	if(type==1){
		int a,b;
		cin>>a>>b;
  
     int dis=(a*a)+(b*b);
	 pq.push(dis);
	}
	
	
	else if(type ==2 ){
		
		
		while(times!=0){
			temp[i]=pq.top();
			i++;
	        pq.pop();	
			times--;
	             }
	cout<<pq.top()<<endl;
	for(int i=0;i<k-1;i++){
		pq.push(temp[i]);
		
	    }
		
	
  }
  
  
   }
  

return 0;

}

Your Mistakes
your approach is not completely correct but
it will give TLE because it has high time complexity

this is because first your are storing unneccasary data as well and also at time of query 2 first you have to pop and then again you have to push this is make time complexity high

Correct Approach

use max heap to solve this question

use Reference Code