Use question 1873 and hduoj1873 of the queue for priority during HDUOj Medical Treatment
Detailed description of STL priority queue http://blog.csdn.net/yueloveme/article/details/47106639#include <stdio. h>
# Include <queue>
Using namespace std;
Struct node
{
Int q, k;
Friend bool operator <(node a, node B) // first compares the q size. If they are equal, they are arranged in k size.
{
If (a. q <B. q) return true;
If (a. q = B. q & a. k> B. k) return true;
Return false;
}
};
Priority_queue <node> que [4]; // queue Array
Int main ()
{
Int n;
While (~ Scanf ("% d", & n ))
{
While (! Que [1]. empty () // clear
Que [1]. pop ();
While (! Que [2]. empty ())
Que [2]. pop ();
While (! Que [3]. empty ())
Que [3]. pop ();
Int h = 0, a, c, I = 1, m [2000];
Char s [4];
Node B;
For (int j = 0; j <n; j ++)
{
Scanf ("% s", s );
If (s [0] = 'I') // enter
{
Scanf ("% d", & a, & c );
B. q = c;
B. k = I ++;
Que [a]. push (B );
}
Else // judge the output
{
Node B;
Scanf ("% d", & );
If (que [a]. empty () printf ("EMPTY \ n ");
Else {printf ("% d \ n", que [a]. top (). k );
Que [a]. pop ();}
}
}
}
Return 0;
} Else
Copyright Disclaimer: This article is an original article by the blogger and cannot be reproduced without the permission of the blogger.