wa,0分,本地测试样例是对的
查看原帖
wa,0分,本地测试样例是对的
1189340
aishiteru_mitsu_ha楼主2024/4/27 18:49
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll n,w,tree[1000010];
ll lowbit(ll x){
	return x&-x;
}
ll sum(ll x){
	int ans=0;
	while(x>=1){
		ans+=tree[x];
		x-=lowbit(x);
	}
	return ans;
}
void add(ll x,ll k){
	while(x<=n){
		tree[x]+=k;
		x+=lowbit(x);
	}
}
int main(){
	cin>>n>>w;
	for(int i=1;i<=w;i++){
		char cnt;
		int a,b;
		cin>>cnt>>a>>b;
		if(cnt=='x'){
			add(a,b);
		}else{
			cout<<sum(b)-sum(a-1)<<endl;
		}
	}
	return 0;
}
2024/4/27 18:49
加载中...