1 #include<stdio.h>
2 #include<string.h>
3 int main()
4 {
5 int n,m,num[10000],x,y,z,d,f = 1,i,r = 0;
6 char str[10];
7 scanf("%d", &m);
8 for(i = 1 ; i <= m;i++)
9 scanf("%d", &num[i]);
10 scanf("%d",&n);
11 r = m;
12 while(n--)
13 {
14 scanf("%s",str);
15 if(strcmp(str,"JOIN") == 0)
16 {
17 scanf("%d", &x);
18 num[++r]=x;
19 }
20 if(strcmp(str, "ASK") == 0 )
21 {
22 scanf("%d", &z);
23 printf("%d\n",num[f+z-1]);//这个地方没有想到应该是f+z-1 本来直接写的z
24 }
25 if(strcmp(str, "LEAVE") == 0)
26 {
27 scanf("%d", &y);
28 for(i = f+y-1;i < r;i++)//这里也没想到应该是f+y-1 直接写的y
29 num[i]=num[i+1];
30 r--;
31 }
32 if(strcmp(str,"LENGTH") == 0)
33 printf("%d\n",r-f+1);
34 if(strcmp(str, "FINISH") == 0)
35 {
36 scanf("%d", &d);
37 f = f+d;
38 }
39 }
40 return 0 ;
41 }