其他分享
首页 > 其他分享> > sdfs

sdfs

作者:互联网

#include<iostream>
#include<cstring>
#include<cstdio>
#define M 1000005
using namespace std;
int t,a,k,i,n,m,minhead,mintail,maxhead,maxtail,minans[M],maxans[M],arr,maxque[M],minque[M];
string s,sb;
void GG(int a)
{
    while(maxhead<=maxtail&&a>maxque[maxtail]) maxtail--;
    maxque[++maxtail]=a;
}
int main(){
    t=-1;
    scanf("%d",&n);
    for(i=1;i<=n;i++)
    {
        while(scanf("%c",&s)==1)
        {
            if(s=="START")
            continue ;
            if(s=="END")
            { 
                maxhead=0;maxtail=0;memset(maxque,0,sizeof(maxque));
               break;
            }
            if(s=='Q')
            {
                if(maxque[maxhead]==0)
                printf("%d",t);
                else
                printf("%d",maxque[maxhead]);}
            if(s=='C')
            {
                scanf("%s%d",&sb,&a);
                GG(a);
            }
            if(s=='G')
            {
                if(maxque[maxhead]>0)
                {
                        maxhead++;
                }
            }
        }
    }
}

 

标签:sdfs,int,maxque,++,maxtail,include,maxhead
来源: https://www.cnblogs.com/Lamboofhome/p/11494529.html