-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhdu 1873 看病要排队.cpp
44 lines (40 loc) · 1.03 KB
/
hdu 1873 看病要排队.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
//STL优先队列priority_queue
#include<iostream>
#include<queue>
//加这个文件是因为杭电的oj不行
#include<string>
using namespace std;
struct Node{
int n, p;
bool operator < (const Node &t) const {
if (p == t.p) return n > t.n;
return p < t.p;
}
}node;
int main() {
int n, id, doc;
string temp;
//没有输入scanf返回-1
while (~scanf("%d", &n)) {
id = 0;
priority_queue<Node> q[3];
while (n--) {
cin>>temp;
if (temp == "IN") {
scanf("%d%d", &doc, &node.p);
node.n = ++id;
q[doc - 1].push(node);
}else {
scanf("%d", &doc);
if (q[doc - 1].empty())
cout << "EMPTY" << endl;
else {
node = q[doc - 1].top();
q[doc - 1].pop();
cout << node.n<<endl;
}
}
}
}
return 0;
}