标签:
1 #include<cstdio> 2 #include<queue> 3 #include<iostream> 4 #include<string> 5 using namespace std; 6 7 struct sick 8 { 9 int priority; 10 int order; 11 bool operator < (const sick &temp)const 12 { 13 if(temp.priority==priority) 14 return order>temp.order; 15 return priority<temp.priority; 16 } 17 }; 18 19 int main() 20 { 21 //freopen("in.txt","r",stdin); 22 int t; 23 while(scanf("%d",&t)!=EOF) 24 { 25 int order=0; 26 priority_queue<sick>q[3]; 27 while(t--) 28 { 29 string event; 30 cin>>event; 31 if(event=="IN") 32 { 33 sick node; 34 int temp1,temp2; 35 scanf("%d%d",&temp1,&temp2); 36 node.priority=temp2; 37 node.order=++order; 38 q[temp1-1].push(node); 39 } 40 else 41 { 42 int temp; 43 scanf("%d",&temp); 44 if(!q[temp-1].empty()) 45 { 46 sick node=q[temp-1].top(); 47 printf("%d\n",node.order); 48 q[temp-1].pop(); 49 } 50 else 51 printf("EMPTY\n"); 52 } 53 } 54 } 55 return 0; 56 }
标签:
原文地址:http://www.cnblogs.com/homura/p/4682971.html