Hostel visit Heap

Only one testcase is passing for my code
#include
#include
using namespace std;
int dist(int p,int q){
return pp+qq;
}

int main() {
int n,k,type;
cin>>n>>k;
priority_queuepq;
while(n–){
cin>>type;
if(type==1){
int x,y;
cin>>x>>y;
if(pq.size()==k){
if(dist(x,y)<pq.top()){
pq.pop();
pq.push(dist(x,y));
}
}
else{
pq.push(dist(x,y));
}
}
else{
cout<<pq.top()<<endl;
}

}

}
I have one more doubt that we are not adding anything in priority queue and we are directly comparing the size of pq with k. Can you please explain this

check out this code

Got it.My doubt is clear now

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.