http://code.bupt.edu.cn/problem/p/108/
#include<stdio.h>
#include<queue>
#include<math.h>
#include<stdlib.h>
#include<string.h>
using namespace std;
struct p
{
int shi;
int xu;
double mo;
friend bool operator < (p t1,p t2)
{
if(t1.mo<t2.mo)
return true;
else
return false;
}
};
int main()
{
int T;
scanf("%d",&T);
for(int k=1;k<=T;k++)
{
int n;
scanf("%d",&n);
priority_queue< p,vector<p>,less<p> > v;
for(int i=1;i<=n;i++)
{
getchar();
char tmp[30];
scanf("%s",tmp);
if(strcmp(tmp,"Insert")==0)
{
p tt;
scanf("%d+i%d",&tt.shi,&tt.xu);
tt.mo=sqrt(tt.shi*tt.shi+tt.xu*tt.xu);
v.push(tt);
printf("Size: %d\n",v.size());
}
else if(strcmp(tmp,"Pop")==0)
{
if(v.size()==0)
printf("Empty!\n");
else
{
p tt=v.top();
v.pop();
printf("%d+i%d\n",tt.shi,tt.xu);
if(v.size()==0)
printf("Empty!\n");
else
printf("Size: %d\n",v.size());
}
}
else
;
}
}
//system("pause");
return 0;
}