I am not getting this
i try it many times.
with priority queue and deque and but
one test case left.
plz help out this.
here is my code …
#include
#include
#include
#include
using namespace std;
int main(){
int q,k;
deque aux;
priority_queue<int,vector ,greater >pq;
int t,x,y;
cin>>q>>k;
while(q--){
cin>>t;
if(t==1){
cin>>x>>y;
pq.push(x*x+y*y);
}
else if(t==2){
for(int i = 1 ; i <k ; i++ ){
aux.push_back(pq.top());
pq.pop();
}
aux.push_back(pq.top());
cout<<pq.top()<<endl;
while(!pq.empty()){
pq.pop();
}
while(!aux.empty()){
pq.push(aux.back());
aux.pop_back();
}
}
}
return 0;
}