标签:
#include<stdio.h> #include<iostream> #include<string.h> #include<algorithm> #include<math.h> using namespace std; struct p{ int num,rp; }people[1000005]; int main(){ int T; scanf("%d",&T); while(T--){ char s[10]; int head=0,first=0,tail=-1,n=1; while(~scanf("%s",s)&&strcmp(s,"END")!=0){ if(s[0]==‘C‘){ char name[6]; int val; scanf("%s%d",name,&val); while(tail>=head&&people[tail].rp<=val) tail--; people[++tail].rp=val; people[tail].num=n++; } else if(s[0]==‘Q‘){ while(tail>=head&&people[head].num<=first) head++; if(tail>=head) printf("%d\n",people[head].rp); else printf("-1\n"); } else if(s[0]==‘G‘) first++; } } return 0; }
标签:
原文地址:http://www.cnblogs.com/general10/p/5414761.html