This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.
#include<bits/stdc++.h>
typedeflonglongLL;
usingnamespacestd;
constintN=2e5+10;
intm,p;
LLc[N];
typedeflonglongLL;
#define lowbit(x) (x & -x)
voidadd(intx,LLd){
for(inti=x;i<N;i+=lowbit(i))c[i]=max(c[i],d);
}
LLquery(intx){
LLres=0;
for(inti=x;i;i-=lowbit(i))res=max(res,c[i]);
returnres;
}
intmain(){
// 加快读入
ios::sync_with_stdio(false),cin.tie(0);
cin>>m>>p;// m次操作,p是模值
intlast=0;// last 是在这个添加操作之前最后一个询问操作的答案(如果之前没有询问操作,则 a=0)。