标签:
7 IN 1 1 IN 1 2 OUT 1 OUT 2 IN 2 1 OUT 2 OUT 1 2 IN 1 1 OUT 1
2 EMPTY 3 1 1
#include<cstdio> #include<cstring> #include<iostream> #include<queue> using namespace std; struct patient { int pri,num; friend bool operator <(patient a,patient b) { if(a.pri==b.pri) return a.num>b.num; return a.pri<b.pri; } }; priority_queue<patient>q[4]; patient temp; int main() { int t,a,b; char str[10]; while(scanf("%d",&t)!=EOF) { int i=1; while(t--) { scanf("%s",str); if(strcmp(str,"IN")==0) { scanf("%d%d",&a,&b);//优先级为b的要求a诊治 temp.num=i++; temp.pri=b; q[a].push(temp); } else { scanf("%d",&a); if(q[a].empty())//如果a医生没病人 { printf("EMPTY\n"); } else { printf("%d\n",q[a].top().num); q[a].pop(); } } } for(i=0;i<4;++i) while(!q[i].empty()) q[i].pop(); } return 0; }
版权声明:本文为博主原创文章,未经博主允许不得转载。
标签:
原文地址:http://blog.csdn.net/yuzhiwei1995/article/details/47099609