• hdu 1873【看病要排队】


    直接模拟。。。

    View Code
     1 #include <iostream>
     2 #include <cstring>
     3 #include <queue>
     4 using namespace std;
     5 
     6 typedef pair<int,int> pii;
     7 
     8 struct node
     9 {
    10     int id,kb;
    11     node(){}
    12     node(int a,int b)
    13     {
    14         id = b;
    15         kb = a;
    16     }
    17     friend bool operator <(const node& a,const node& b)
    18     {
    19         if(a.kb == b.kb)
    20             return a.id > b.id;
    21 
    22         return a.kb < b.kb;
    23     }
    24 };
    25 
    26 int main()
    27 {
    28     int n;
    29     while(cin >> n)
    30     {
    31         priority_queue<node> q[4];
    32 
    33         char str[5];
    34         int id = 1;
    35         while(n --)
    36         {
    37             int a;
    38             cin >> str >> a;
    39             if(str[0] == 'I')
    40             {
    41                 int b;
    42                 cin >> b;
    43                 q[a].push(node(b,id));
    44                 id ++;
    45             }
    46             else
    47             {
    48                 if(q[a].empty())
    49                 {
    50                     cout << "EMPTY" << endl;
    51                 }
    52                 else
    53                 {
    54                     cout << q[a].top().id << endl;
    55                     q[a].pop();
    56                 }
    57             }
    58         }
    59 
    60     }
    61     return 0;
    62 }
  • 相关阅读:
    新的开始——3.3
    第一个周末——3.2
    恋爱知识大增——周五3.1
    相安无事——周四2.28
    好几天没写了。。。——周三2.27
    开学第二天——2.26
    开学第一天——2.25
    华为
    微软 Microsoft
    谷歌 google
  • 原文地址:https://www.cnblogs.com/Shirlies/p/2697589.html
Copyright © 2020-2023  润新知