luogu#P4868. Preprefix sum
Preprefix sum
Problem Description
The prefix sum is defined as .
The preprefix sum (preprefix sum) takes as the original sequence and computes the prefix sum again. Let the -th value of this second prefix sum be .
Given a sequence of length , there are two types of operations:
Modify i x: Change to .Query i: Query .
Input Format
The first line contains two integers , representing the length of the sequence and the number of operations.
The next line contains numbers, the given sequence .
The next lines each contain one operation, with the format described above.
Output Format
For each query operation, output one line containing the value of being queried.
5 3
1 2 3 4 5
Query 5
Modify 3 2
Query 5
35
32
Hint
Constraints: , and at any time .
Translated by ChatGPT 5