#include <iostream> #include <queue> #include <string> using namespace std; struct plurality{ int num; int i; plurality(int num,int i):num(num),i(i) {} }; bool operator <(plurality x,plurality y){ int xdata = x.num*x.num+x.i*x.i; int ydata = y.num*y.num+y.i*y.i; if (xdata==ydata){ return x.i>y.i; } else{ return xdata<ydata; } } int main(){ int n; string str,s; priority_queue<plurality> plQ; cin>>n; while (n--){ cin>>str; if (str == "Pop"){ if (plQ.empty()){ cout<<"empty"<<endl; } else{ plurality number = plQ.top(); plQ.pop(); cout<<number.num<<"+i"<<number.i<<endl; cout<<"SIZE = "<<plQ.size()<<endl; } } else if (str == "Insert"){ cin>>s; int end = s.find('+'); plQ.push(plurality(stoi(s.substr(0,end)), stoi(s.substr(end+2)))); cout<<"SIZE = "<<plQ.size()<<endl; } } return 0; }