志愿者选拔

Problem 1894 志愿者选拔
#include
#include
#include
using namespace std;
struct node
{
    int rp;
    int id;
}p[1000000];
int main()
{
    int t;
    cin>>t;
    while(t--)
    {
        memset(p,0,sizeof(p));
        string s;
        cin>>s;
        int head=0;
        int tail=-1;
        int num=0;
        int leave=0;
        while(true)
        {
            char s1;
            cin>>s1;
 

if(s1=='E') break; if(s1=='C') { node tmp; tmp.id=++num; string name; cin>>name; cin>>tmp.rp; while(head<=tail&&p[tail].rp<=tmp.rp) tail--; p[++tail]=tmp; } else if(s1=='Q') { while(head<=tail&&p[head].id<=leave) head++; if(head>tail)printf("-1\n"); else printf("%d\n",p[head].rp); } } } return 0;}
 
  
 

你可能感兴趣的:(数据结构)