#include<cstdio> #include<queue> #include<string> using namespace std; struct Complx { int re; int im; }; bool operator < (Complx lhs, Complx rhs) { return lhs.re * lhs.re + lhs.im * lhs.im < rhs.re * rhs.re + rhs.im * rhs.im; } int main() { int n; scanf("%d", &n); priority_queue< Complx> myQue; for (int i = 0 ; i < n ; ++i) { char arr[30]; scanf("%s", arr); string s = arr; if (s == "Pop") { if (myQue.empty()) { printf("empty\n"); } else { printf("%d+i%d\n", myQue.top().re, myQue.top().im); myQue.pop(); printf("SIZE = %d\n", myQue.size()); } } else if (s == "Insert") { int re, im; scanf("%d+i%d", &re, &im); Complx c; c.re = re; c.im = im; myQue.push(c); printf("SIZE = %d\n", myQue.size()); } } }