Sum on a segment#4255

Sum on a segment

1 sekunt
128 megabaýt
Örän ýeňil

An array of integers is given. Your task is to process queries of two types: update an element of the array and find the sum of elements on a given segment.

Giriş

The first line contains two integers and k~(1 \le n \le 10^5, 0 \le k \le 10^5) — the number of elements in the array and the number of queries, respectively.

Each of the next lines contains a query of one of the following two types:

  • A i x — assign the value to the -th element of the array (1 \le i \le n, 0 \le x \le 10^9);

  • Q l r — find the sum of the elements in the array from position to position , inclusive (1 \le l \le r \le n).

Initially, all elements of the array are equal to zero.

Çykyş

For each query of type Q l r, print the sum of the elements in the segment [l, r] on a separate line.

Mysallar

1-nji mysal

Loading
Loading