我并没有多想,他们是用的数组模拟队列,然而我就是优化循环次数过得

#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int node[];
int main()
{
int t;
scanf("%d",&t);
while(t--)
{
char op[],name[];
int all = ,s = ,max = -,maxid = ;
while(~scanf("%s",op))
{
if(op[] == 'S') continue;
if(op[] == 'C')
{
scanf("%s",name);
scanf("%d",&node[all]);
if(node[all] > max)
{
max = node[all];
maxid = all;
}
++all;
}
else if(op[] == 'G')
s++;
else if(op[] == 'Q')
{
if(s > all)
{
puts("-1");
continue;
}
if(s < maxid)
{
printf("%d\n",max);
continue;
}
max = -;
for(int i = s;i < all;i++)
{
if(node[i] > max)
{
max = node[i];
maxid = i;
}
}
if(max == -)
{
puts("-1");
continue;
}
printf("%d\n",max);
}
else break;
}
}
return ;
}
04-27 17:44