zoukankan      html  css  js  c++  java
  • 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 }
  • 相关阅读:
    目录
    mysql 常用命令复习
    mysql备份及pymysql
    mysql 表操作
    mysql 库操作
    mysql 数据库
    各种推导式
    python 之I/O模型
    python 之进程
    python之 多线程(二)
  • 原文地址:https://www.cnblogs.com/Shirlies/p/2697589.html
Copyright © 2011-2022 走看看