标签:des style io color ar os sp java strong
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 <algorithm> #include <iostream> #include <cstring> #include <cstdlib> #include <string> #include <cctype> #include <vector> #include <cstdio> #include <cmath> #include <queue> #include <stack> #include <map> #include <set> #define ll long long #define maxn 116 #define pp pair<int,int> #define INF 0x3f3f3f3f #define max(x,y) ( ((x) > (y)) ? (x) : (y) ) #define min(x,y) ( ((x) > (y)) ? (y) : (x) ) using namespace std; int n,num; struct node { int tag,w; friend bool operator <(node a,node b) { if(a.w!=b.w) return a.w<b.w; return a.tag>b.tag; } }; int main() { while(scanf("%d",&n)!=EOF) { char op[5];int a,b; priority_queue <node> q1; priority_queue <node> q2; priority_queue <node> q3; num=1; while(n--) { scanf("%s",op); if(!strcmp(op,"IN")) { scanf("%d%d",&a,&b); node tem; tem.tag=num++; tem.w=b; if(a==1) q1.push(tem); else if(a==2) q2.push(tem); else if(a==3) q3.push(tem); } else if(!strcmp(op,"OUT")) { scanf("%d",&a); if(a==1) { if(!q1.empty()) { node f=q1.top(); q1.pop(); printf("%d\n",f.tag); } else puts("EMPTY"); } else if(a==2) { if(!q2.empty()) { node f=q2.top(); q2.pop(); printf("%d\n",f.tag); } else puts("EMPTY"); } else if(a==3) { if(!q3.empty()) { node f=q3.top(); q3.pop(); printf("%d\n",f.tag); } else puts("EMPTY"); } } } } return 0; }
标签:des style io color ar os sp java strong
原文地址:http://blog.csdn.net/qq_16255321/article/details/41155319