求助!!本地样例全过,提交全WA
查看原帖
求助!!本地样例全过,提交全WA
486799
BlackPanda楼主2022/7/12 13:56
#include <bits/stdc++.h>
using namespace std;

#define LL long long 
#define lowbit(x) x&(-x)

int n, w, x, y;
char t;
int c[100005];

void add(LL x, LL v){
	for(LL i = x; i <= n; i+=lowbit(i))
		c[i] += v;
}

LL ask(LL x){
	LL sum = 0;
	for(LL i = x; i >= 1; i-=lowbit(i)){
		sum += c[i];
	}
	return sum;
}

int main(){
	scanf("%d%d",&n,&w);
	while(w--){
		cin >> t >> x >> y;
		if(t == 'x'){
			add(x,y);
		}
		else if(t == 'y'){
			printf("%lld\n", ask(y)-ask(x-1));
		}
	}
	return 0;
}


2022/7/12 13:56
加载中...