Use question 1873 and hduoj1873 of the queue for priority during HDUOj Medical Treatment

Source: Internet
Author: User

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.