暴力效率不高,共830ms
by 空の軌跡 @ 2018-10-18 16:44:26
```
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
int low[200010],mod,cnt=1;
int main()
{
ios::sync_with_stdio(0);
int a,b,t=0;char c;
cin>>a>>mod;
for(int i=1;i<=a;i++)
{
cin>>c>>b;
if(c=='A')
{
b=(b+t)%mod;
low[cnt]=b;
int k=cnt-1;
while(low[k]<b)
{
low[k]=b;
k--;
}
cnt++;
}
if(c=='Q')
{
t=low[cnt-b];
cout<<t<<"\n";
}
}
}
```
by 空の軌跡 @ 2018-10-18 16:45:37