hdu--1873--看病要排队

#include<iostream>
#include<queue>
#include<string>
struct news{
    int lev;
    int num;
    bool operator <(const news a)const{
        return this->lev==a.lev?this->num>a.num:this->lev<a.lev;
    }
};
using namespace std;
int main()
{
    int n;
    while(cin>>n)    
    {
        int cut=0;
        priority_queue<news> q[4];
        for(int i=0;i<n;++i)
        {
            string str;
            cin>>str;
            if(str == "IN")
            {
                cut++;
                news so;
                int k;
                cin>>k>>so.lev;
                so.num=cut;
                q[k].push(so);
            }
            else if(str == "OUT")
            {
                int i;
                cin>>i;
                if(!q[i].empty())
                {
                    cout<<q[i].top().num<<endl;
                    q[i].pop();
                }
                else cout<<"EMPTY\n";
            }
        }
    }
    return 0;
}

 

posted @ 2017-02-09 16:00  朤尧  阅读(265)  评论(0编辑  收藏  举报