68820
A couple of days without the water.
#include <stdio.h> #include <string.h> #include <algorithm> #include <queue> #define MAX 1000100using namespace Std;int n,m;int sum[max<<2];void pushup (int o) {sum[o]=sum[o<<1]+sum[o<<1|1] ;} void Gettree (int o,int l,int R) {if (l==r) {scanf ("%d", &sum[o]); return; } int mid= (L+R) >>1; Gettree (O<<1,l,mid); Gettree (O<<1|1,MID+1,R); Pushup (o);} void update (int o,int l,int r,int pos,int val) {if (l==r) {sum[o]+=val; return; } int mid= (L+R) >>1; if (pos<=mid) update (o<<1,l,mid,pos,val); else update (o<<1|1,mid+1,r,pos,val); Pushup (o);} int find (int o,int l,int r,int l,int R) {if (l<=l&&r>=r) return sum[o]; int mid= (L+R) >>1; int ans=0; if (r<=mid) ans+=find (o<<1,l,mid,l,r); else if (l>mid) ans+=find (o<<1|1,mid+1,r,l,r); else {ans+=find (O<<1,l,mid,L,MID); Ans+=find (O<<1|1,MID+1,R,MID+1,R); } return ans; int main () {int N,m,a,b;char op[20];scanf ("%d%d", &n,&m), Gettree (1,1,n), while (m--) {scanf ("%s", op); scanf ("%d %d ", &a,&b), if (op[0]== ' Q ') printf ("%d\n ", Find (1,1,n,a,b)); else update (1,1,N,A,B);} return 0;}