如题,vscode都过了,但交就炸了,试了在线ide没re但输出全部都是0,大家有什么头猪吗
#include<bits/stdc++.h>
using namespace std;
const int maxn=200050;
#define ll long long
inline ll read()
{
ll x=0;
ll f=1;
char ch=getchar();
for(;!isdigit(ch);ch=getchar())f=(ch!='-');
for(;isdigit(ch);ch=getchar())x=x*10+(ch^48);
return x*f;
}
ll maxx[maxn][21];
int r,n;
ll m;
void insert(ll x)
{
r++;
maxx[r][0]=x;
for(int i=1;r-(1<<i)>=0;i++)
{
maxx[r][i]=max(maxx[r][i-1],maxx[r-(1<<(i-1))][i-1]);
}
}
inline ll query(int l,int r)
{
int k=log2(r-l+1);
return max(maxx[r][k],maxx[l+(1<<k)-1][k]);
}
int main()
{
n=read();
m=read();
int t=0;
for(int i=1;i<=n;i++)
{
char ch=getchar();
if(ch=='A')
{
ll w=read();
t=(t+w)%m;
insert(t);
}
else
{
ll len=read();
t=query(r-len+1,r);
printf("%d\n",t);
}
}
return 0;
}