我是靠谱客的博主 跳跃大树,这篇文章主要介绍hdu1873 看病要排队,现在分享给大家,希望可以做个参考。

主要是学习一下优先队列的使用

code:

#include <queue>
#include <cstdio>
using namespace std;

struct node
{
    int id,lv;
    friend bool operator < (const node x,const node y)
    {
        if(x.lv==y.lv)
        {
            return x.id>y.id;
        }
        return x.lv<y.lv;
    }

}tmp;

int main()
{
    char str[5];
    int n,i,a,b;
    while(~scanf("%d",&n))
    {
        tmp.id=0;
        priority_queue<node> q[4];
        for(i=1;i<=n;i++)
        {
            scanf("%s",str);
            if(str[0]=='I')
            {
                tmp.id++;
                scanf("%d%d",&a,&b);
                tmp.lv=b;
                q[a].push(tmp);
            }else{
                scanf("%d",&a);
                if(!q[a].empty())
                {
                    printf("%dn",q[a].top().id);
                    q[a].pop();
                }else{
                    puts("EMPTY");
                }
            }
        }
    }
    return 0;
}


最后

以上就是跳跃大树最近收集整理的关于hdu1873 看病要排队的全部内容,更多相关hdu1873内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(124)

评论列表共有 0 条评论

立即
投稿
返回
顶部