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