Given an array and an index , the -th partial sum of is . Here, you have to implement a data structure to efficiently compute partial sums. The operations you must consider are the creation of an array with all its values initialized to zero, the modification of a value, and the query of a partial sum.
Input consists of a non-empty sequence of commands. Every command begins with a letter to identify it, followed by one or two integer-number parameters. These are the possible commands:
“r ”
resets (or creates) an array of
integer numbers to zero. Assume
.
“s ”
sets the possition
to
.
Assume
and
.
“g ”
gets (and prints) the
-th
partial sum. Assume
.
In general, there are much more set and get commands than reset commands. The first command is always a reset.
For each get command, print the corresponding partial sum. Print the output corresponding to each reset command on a unique line, separated by spaces.
Author: Jordi Petit
Generation: 2026-01-25T11:35:07.529Z
© Jutge.org, 2006–2026.
https://jutge.org