hdu1873优先队列

 #include<stdio.h>
#include<queue>
using namespace std;
struct node
{
int id;
int val;
friend bool operator< (node a,node b)
{
if(a.val!=b.val)
return a.val<b.val;
else
{
return a.id>b.id;
}
}
};
int n;
int main()
{
int i,j;
char s[];
int num,set;
while(scanf("%d",&n)!=EOF)
{
num=;
node temp;
priority_queue<node>q[];
for(i=;i<=n;i++)
{
scanf("%s",s);
if(s[]=='I')
{
scanf("%d %d",&set,&temp.val);
temp.id=num++;
q[set].push(temp);
}
else
{
scanf("%d",&set);
if(q[set].empty())
{
printf("EMPTY\n");
continue;
}
node exm=q[set].top();
q[set].pop();
printf("%d\n",exm.id);
}
}
}
}
上一篇:poj 2996 Help Me with the Game(模拟)


下一篇:构建混合云:配置Azure site to site VPN连接(1)