这题真的非常水了
如果不会 右转【模板】树状数组 2
基本上是一模一样的
#include <bits/stdc++.h>
#define lowbit(x) x&-x
using namespace std ;
typedef long long LL;
inline LL read(){ LL x=0; int f=1; char ch=getchar();
while(!isdigit(ch)) { if (ch=='-') f=-1; ch=getchar(); }
while(isdigit(ch)) x=(x<<1)+(x<<3)+(ch^48),ch=getchar(); return x*f;
}
int n,m;
int tree[2000000+10];
inline void add (int x, int k){
while (x<=n) tree[x]+=k,x+=lowbit(x);
return ;
}
inline LL sum ( int x ){
LL ans = 0;
while (x) {
ans += tree [x] ;
x -= lowbit(x);
}
return ans ;
}
signed main() {
n=read() , m=read ();
for(register int i=1;i<=m;i++) {
char x;
cin>>x;
int y=read() , z=read();
if (x == 'x') add(y , z);
if (x == 'y') cout << sum (z) - sum (y - 1) <<endl ;
}
return 0;
}