//author:luckYrat(twitter:@luckYrat_) //#include //def #include #include #include #include //array #include #include #include #include #include #include #include using namespace std; using ll = long long; using P = pair; #define anyfill(n,s) setw(n) << setfill(s) #define loop(s) for(int i = 0; s > i; i++) #define rep(i,q) for(int i = 0; (q) > i; i++) #define repp(i,n,q) for(int i = n; (q) > i; i++) #define dep(i,q) for(int i = (q); 0 < i; i--) #define MAX 1000000000 const int mod = 1000000007; #define EPS (1e-10) #define pb push_back #define fir first #define scn second #define ednl endl #define YesNo(a) (a?"Yes":"No") #define YESNO(a) (a?"YES":"NO") #define yesno(a) (a?"yes":"no") P ar[4] = {{0,1},{0,-1},{1,0},{-1,0}}; /* 確認ポイント cout << fixed << setprecision(n) << 小数計算//n桁の小数表記になる vector.unique()は隣接した同じ要素を削除するので先にソートをする 計算量は変わらないが楽できるシリーズ C++11以降でmin({a,b,c...})で複数個のmic,maxを処理できる min(max)_element(iter,iter)で一番小さい(大きい)値のポインタが帰ってくる count(iter,iter,int)でintがiterからiterの間にいくつあったかを取得できる */ template struct BIT{//1_Indexed int n; vector bit; vector range; BIT(int n_):n(n_+1),bit(n,0),range(n,0){} T sum(int a){ T ret = 0; for(int i = a; i > 0; i -= i & -i) ret += bit[i]; return ret; } T rangesum(int a){ T ret = 0; for(int i = a; i > 0; i -= i & -i) ret += range[i]; return ret; } void add(int a,T w){ for(int i = a; i <= n; i += i & -i)bit[i] += w; } void rangeadd(int x,int y,T w){// x < y y++; for(int i = x; i <= n; i += i & -i)range[i] += w; for(int i = y; i <= n; i += i & -i)range[i] -= w; } T query(int l,int r){ if(r==1){ return sum(l)+rangesum(l); } return sum(l)-sum(r-1)+rangesum(l); } }; __attribute__((constructor)) void initial() { cin.tie(0); ios::sync_with_stdio(false); } int main(){ int n,q;cin>>n>>q; vector A(n); vector B(n); for(int i = 0; n > i; i++){ cin>>A[i]; B[i] = 0; } BIT Z(n); for(int i = 0; q > i; i++){ char c;long long x,y;cin>>c>>x>>y; if(c == 'A'){ //bit[x]+=y; if(Z.query(x,x)){ int m = Z.query(x,x); B[x-1] += m*A[x-1]; Z.add(x,m*-1); } A[x-1] += y; }else{ Z.rangeadd(x,y,1); } } for(int j = 0; n > j; j++){ cout << B[j]+Z.query(j+1,j+1)*A[j]; if(j+1 != n)cout << " "; } cout << endl; }