#include <bits/stdc++.h>
using namespace std;
int _queue[10010];
int main()
{
int n, m, top = 0;
char s[10];
cin >> m;
for(int i = 0; i < m; i++)
{
int a;
cin >> a;
_queue[++top] = a;
}
cin >> n;
while(n --)
{
scanf("%s", s);
if(strcmp(s, "JOIN") == 0)
{
int a;
cin >> a;
_queue[++top] = a;
}
else if(strcmp(s, "ASK") == 0)
{
int a;
cin >> a;
cout << _queue[a] << endl;
}
else if(strcmp(s, "LEAVE") == 0)
{
int a;
cin >> a;
for(int i = a; i < top; i++)
{
_queue[i] = _queue[i+1];
}
--top;
}
else if(strcmp(s, "LENGTH") == 0)
{
cout << top << endl;
}
else if(strcmp(s, "FINISH") == 0)
{
int a, k = 0;
cin >> a;
for(int i = 1; i <= top-a; i++)
{
_queue[i] = _queue[i+a];
}
top -= a;
}
}
return 0;
}
09-13
647
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)