int main() {
priority_queue<long long int,vector<long long int>,greater<long long int>> s;
int t,k;
cin>>t>>k;
while(t--){
long long int q,v1,v2;
cin>>q;
if(q==1){
cin>>v1>>v2;
long long int res = (v1*v1) + (v2*v2);
s.push(res);
}
if(q==2){
stack <long long int> sta;
int l = k-1;
while(l--){
sta.push(s.top());
s.pop();
}
cout<<s.top()<<"\n";
while(!sta.empty()){
s.push(sta.top());
sta.pop();
}
}
}
return 0;
}
This is my main code. I’m failing the fourth test case. Initially I did it using set and I passed only 3rd test case. Then I used priority queue, now I’m failing only 4rth test case. Hint / Help needed.