#include using namespace std; #include namespace mp=boost::multiprecision; template class segment_tree{ public: vector tree; type unit; function fn; segment_tree(vector a,function fn,type unit){//aは配列、fnはモノイドの演算、unitは単位元 int n=0; long long N=a.size(); while(N>(1<=0;--i){ for(int j=(1<unit=unit; this->fn=fn; } type get(long long left,long long right){//区間の指定法は半開区間 int n=0; type ans=unit; while((1<=0;--i){ if(left==right){ break; } if(left%2){ ans=fn(ans,tree[((1<=0;--i){ index/=2; tree[(1<>N>>Q; vector c(Q+N,'A'); vector x(Q+N),y(Q+N); for(int i=0;i!=N;++i){ x[i]=i+1; cin>>y[i]; } for(int i=N;i!=Q+N;++i){ cin>>c[i]>>x[i]>>y[i]; } vector b(N,0); segment_tree t(vector(N+1,0),[](int a,int b){return a+b;},0); for(int i=Q+N-1;i>=0;--i){ if(c[i]=='B'){ t.update(x[i]-1,t.get(x[i]-1,x[i])+1); t.update(y[i],t.get(y[i],y[i]+1)-1); }else{ b[x[i]-1]+=t.get(0,x[i])*y[i]; } } for(int i=0;i