zoj 2724 Windows Message Queue(最小优先队列+STL)

题意:模拟window 进程

#include<iostream>
#include<cstdio>
#include<string.h>
#include<string>
#include <queue>
using namespace std;
struct msg
{
   string name;
   int sum,val;
   bool operator < (const msg &a) const
   {
       return a.val<val;
   }
};
int main()
{
    char str[100];
    priority_queue <msg> p;
    while(scanf("%s%*c",str)!=EOF)
    {
        if(strcmp(str,"GET")==0)
        {
            if(!p.empty())
            {
                msg q=p.top();
                cout<<q.name<<" "<<q.sum<<endl;
                p.pop();
            }
            else
            {
                puts("EMPTY QUEUE!");
            }
        }
        else
        {
            msg q;cin>>q.name>>q.sum>>q.val;
            p.push(q);
        }
    }
    return 0;
}
原文地址:https://www.cnblogs.com/skyming/p/2457360.html