mirror of
https://github.com/Kiritow/OJ-Problems-Source.git
synced 2024-03-22 13:11:29 +08:00
ed2de2e423
1500-1599
54 lines
1.0 KiB
C++
54 lines
1.0 KiB
C++
#include<iostream>
|
|
#include<cstdio>
|
|
#include<cstring>
|
|
#include<cmath>
|
|
#include<queue>
|
|
#include<stack>
|
|
using namespace std;
|
|
struct node
|
|
{
|
|
char name[20];
|
|
int par,pri,id;
|
|
friend bool operator < (node a,node b)
|
|
{
|
|
if(a.pri!=b.pri)
|
|
{
|
|
return a.pri>b.pri;
|
|
}
|
|
else return a.id>b.id;
|
|
}
|
|
};
|
|
int main()
|
|
{
|
|
char c[5],na[20];
|
|
int pout,cnt=0,pcmp;
|
|
node t;
|
|
priority_queue<node> q;
|
|
while(scanf("%s",c)!=EOF)
|
|
{
|
|
if(c[0]=='P')
|
|
{
|
|
scanf("%s %d %d",na,&pout,&pcmp);
|
|
strcpy(t.name,na);
|
|
t.par=pout;
|
|
t.pri=pcmp;
|
|
t.id=++cnt;
|
|
q.push(t);
|
|
}
|
|
else
|
|
{
|
|
if(!q.empty())
|
|
{
|
|
t=q.top();
|
|
q.pop();
|
|
printf("%s %d\n",t.name,t.par);
|
|
}
|
|
else
|
|
{
|
|
printf("EMPTY QUEUE!\n");
|
|
}
|
|
}
|
|
}
|
|
return 0;
|
|
}
|