HDU1873

来源:互联网 发布:sql去重复列名 编辑:程序博客网 时间:2024/06/06 08:33

锻炼一下队列

#include<iostream>#include<functional>#include<queue>#include<string>#include<vector>#include<cstdio>#include<cstdlib>using namespace std;struct ren {    int x;    int quanzhong;    bool operator < (const ren &a) const    {        if (quanzhong == a.quanzhong)return x > a.x;        return quanzhong<a.quanzhong;    }};int main(){    int n;    while (cin >> n)    {        priority_queue<ren>que4[4];        long long  pp = 0;        while (n--)        {            char ssss[80];            cin >> ssss;            if (ssss[0] == 'I')            {                pp++;                int c, d;                scanf("%d%d", &c, &d);                ren w = { pp,d };                que4[c].push(w);            }            else            {                int e;                cin >> e;                if (que4[e].empty())puts("EMPTY");                else                {                    cout << que4[e].top().x << endl;                    que4[e].pop();                }            }        }    }    return 0;}
0 0
原创粉丝点击