HDU 1873 queue for medical treatment (priority queue)

Source: Internet
Author: User
# 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)

Related Article

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.