Finally, some sales figures get CORRECTED after the fact (a data-entry fix), interleaved with new range-sum requests — Shuvo needs a structure that handles both live updates and fast range queries. Read N integers, then process Q operations of two types: "U i v" (set a[i] = v) or "Q l r" (print sum of a[l..r]). Since updates are interleaved with queries, a plain prefix-sum array won't work efficiently — implement a Fenwick Tree (Binary Indexed Tree) for O(log N) per operation.
Input
Line1: N Q. Line2: N integers. Next Q lines: either "U i v" or "Q l r".
Output
One line per query operation: the requested sum.
Constraints
1 ≤ N, Q ≤ 10^5
Sample Input
5 3 1 2 3 4 5 Q 1 5 U 3 10 Q 1 5
Sample Output
15 22
main.c
Loading editor…
Write C, then Run (custom I/O) or Submit (sample tests). ⌘/Ctrl+Enter submits.