# Include <stdio. h >#include <algorithm> # include <queue> using namespace STD; struct node {int y; int val; int num; friend bool operator <(node N1, node N2) {If (n1.val = n2.val) return n1.num> n2.num; // return n1.val <n2.val; // from large to small }}; struct node temp; int main () {int N, I, a, B; int t; char s [5]; priority_queue <node> A, B, C; while (~ Scanf ("% d", & N) {T = 0; while (! A. Empty () A. Pop (); While (! B. Empty () B. Pop (); While (! C. empty () c. pop (); for (I = 0; I <n; I ++) {scanf ("% s", S); If (strcmp (S, "in ") = 0) {scanf ("% d", & A, & B); if (a = 1) {temp. val = B; temp. num = ++ t;. push (temp); // A Doctor} else if (a = 2) {temp. val = B; temp. num = ++ t; B. push (temp); // doctor B} else {temp. val = B; temp. num = ++ t; C. push (temp); // C Doc} else {scanf ("% d", & A); if (a = 1) {if (. empty () {printf ("Empty \ n"); continue;} temp =. top ();. pop (); printf ("% d \ n", temp. num);} else if (a = 2) {If (B. empty () {printf ("Empty \ n"); continue;} temp = B. top (); B. pop (); printf ("% d \ n", temp. num);} else {If (C. empty () {printf ("Empty \ n"); continue;} temp = C. top (); C. pop (); printf ("% d \ n", temp. num) ;}}} return 0 ;}
HDU 1873 queue for medical treatment (priority queue)