你们猜为什么,怎么改?
#include <functional>
#include <algorithm>
#include <iostream>
#include <fstream>
#include <sstream>
#include <iomanip>
#include <numeric>
#include <cstring>
#include <cassert>
#include <cstdio>
#include <string>
#include <vector>
#include <bitset>
#include <queue>
#include <stack>
//#include <cmath>
#include <ctime>
#include <list>
#include <set>
#include <map>
using namespace std;
#define MAXN 400010
long long addv[MAXN];
long long sumv[MAXN];
int y1, y2;
void maintain(int o, int L, int R) {
int lc = o*2, rc = o*2+1;
if (R > L) {
sumv[o] = sumv[lc] + sumv[rc];
}
sumv[o] += addv[o] * (R-L+1);
if (R == L) addv[o] = 0;
}
int v;
void update(int o, int L, int R) {
int lc = o*2, rc = o*2+1;
if (y1 <= L && R <= y2) {
addv[o] += v;
} else {
int M = L + (R-L)/2;
if (y1 <= M) update(lc, L, M);
if (y2 > M) update(rc, M+1, R);
}
maintain(o, L, R);
}
long long _sum;
void query(int o, int L, int R, long long add) {
if (y1 <= L && R <= y2) {
_sum += sumv[o] + add * (R-L+1);
} else {
int M = L + (R-L)/2;
if (y1 <= M) query(o*2, L, M, add + addv[o]);
if (y2 > M) query(o*2+1, M+1, R, add + addv[o]);
}
}
int main()
{
int N, M;
cin >> N >> M;
for (int i = 1; i <= N; ++i) {
scanf("%d", &v);
y1 = y2 = i;
update(1, 1, N);
}
memset(addv, 0, sizeof addv);
for (int i = 0; i != M; ++i) {
char C;
int A, B;
getchar();
scanf("%c%d%d", &C, &A, &B);
switch(C) {
case 'Q':
y1 = A; y2 = B;
_sum = 0;
query(1, 1, N, 0);
printf("%I64d\n", _sum);
break;
case 'C':
scanf("%d", &v);
y1 = A; y2 = B;
update(1, 1, N);
}
}
return 0;
}