#include
#include
using namespace std;
typedef long long ll;
int main() {
priority_queue pq;
int Q,K;
cin>>Q>>K;
while(Q–)
{
int t;
cin>>t;
if(t == 1)
{
int x,y;
cin>>x>>y;
ll r = x*x + y*y;
pq.push( r );
}
else if(t == 2)
{
while(pq.size()>K)
pq.pop();
if(pq.size() == K)
cout<<pq.top()<<endl;
}
}
return 0;
}
This code gets wrong-answer in TEST CASE 1.
Please tell me what is wrong in my code ?