#include using namespace std; #define fs first #define sc second #define pb push_back #define mp make_pair #define eb emplace_back #define ALL(A) A.begin(),A.end() #define RALL(A) A.rbegin(),A.rend() typedef long long LL; typedef pair P; template inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; } template inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; } template T gcd(T a,T b){return b?gcd(b,a%b):a;} const LL mod=1000000007; const LL LINF=1LL<<62; const int INF=1<<30; int dx[]={1,0,-1,0,1,-1,1,-1}; int dy[]={0,1,0,-1,1,-1,-1,1}; static const int MAX_SIZE = 1 << 20; LL segMax[2 * MAX_SIZE - 1], segAdd[2 * MAX_SIZE - 1]; //区間[a, b)に値xを加算する. void add(int a, int b, LL x, int k = 0, int l = 0, int r = MAX_SIZE) { if (r <= a || b <= l) return; if (a <= l && r <= b){ segAdd[k] += x; return; } add(a, b, x, k * 2 + 1, l, (l + r) / 2); add(a, b, x, k * 2 + 2, (l + r) / 2, r); segMax[k] = max(segMax[k * 2 + 1] + segAdd[k * 2 + 1], segMax[k * 2 + 2] + segAdd[k * 2 + 2]); } LL getMax(int a, int b, int k = 0, int l = 0, int r = MAX_SIZE) { if (r <= a || b <= l) return 0; if (a <= l && r <= b) return (segMax[k] + segAdd[k]); LL left = getMax(a, b, k * 2 + 1, l, (l + r) / 2); LL right = getMax(a, b, k * 2 + 2, (l + r) / 2, r); return (max(left, right) + segAdd[k]); } int main(){ int n,q;cin >> n >> q; vector a(n); for (int i = 0; i < n; i++) { cin >> a[i]; } vector ans(n,0); map> m; while(q--){ char c;cin >> c; LL x,y;cin >> x >> y; x--; if(c=='A'){ auto t = getMax(x,x+1); m[x].pb(mp(t,y)); } else{ add(x,y,1); } } for (int i = 0; i < n; i++) { auto t = getMax(i,i+1); ans[i] = t * a[i]; for (int j = 0; j < m[i].size(); j++) { ans[i] += (t - m[i][j].fs) * m[i][j].sc; } } for (int i = 0; i < n; i++) { cout << ans[i] << (i == n-1?"\n":" "); } return 0; }