Олимпиадный тренинг

Задача 29650. Sum on segment - 2


Задача

Темы: sqrt декомпозиция

Given an array a of length n (\(1 <= n <= 2 \cdot 10^6\)< /span>, \(1 <= a_i <= 10^9\)). Also given m (\(1 <= m <= 500\)) queries like t, l, r (\(0 <= t <= 1\), \(1 <= l <= r <= n\)).

If \(t = 0\), then the query should display the sum of numbers in the segment from l to r inclusive. If \(t = 1\), then element number l is set to r. Elements are numbered from 1 to n

 

Examples
# Input Output
1
5
1 2 3 4 5
4
0 1 2
1 1 5
0 1 2
0 1 1
3
7
5