/* -*- coding: utf-8 -*- * * 1000.cc: No.1000 Point Add and Array Add - yukicoder */ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; /* constant */ const int MAX_N = 200000; /* typedef */ typedef long long ll; template struct BIT { int n; T bits[MAX_N + 1]; BIT() {} BIT(int _n) { init(_n); } void init(int _n) { n = _n; memset(bits, 0, sizeof(bits)); } T sum(int x) { T s = 0; while (x > 0) { s += bits[x]; x -= (x & -x); } return s; } void add(int x, T v) { while (x <= n) { bits[x] += v; x += (x & -x); } } }; /* global variables */ ll as[MAX_N], sbs[MAX_N]; BIT bit; /* subroutines */ /* main */ int main() { int n, q; scanf("%d%d", &n, &q); for (int i = 0; i < n; i++) scanf("%lld", as + i); bit.init(n + 1); while (q--) { char s[4]; int x, y; scanf("%s%d%d", s, &x, &y); if (s[0] == 'A') { x--; as[x] += y; sbs[x] += (ll)y * bit.sum(x + 1); } else { bit.add(x, 1); bit.add(y + 1, -1); } } for (int i = 0; i < n; i++) { if (i) putchar(' '); printf("%lld", as[i] * bit.sum(i + 1) - sbs[i]); } putchar('\n'); return 0; }