#K68052. Tree Health Management

    ID: 32778 Type: Default 1000ms 256MiB

Tree Health Management

Tree Health Management

You are given an array of n integers representing the health scores of n trees. You need to process queries of two types:

  • Update Operation: Change the health score of a tree. Formally, for a query of the form 1 x y, update the score of the x-th tree to y.
  • Range Sum Query: Compute the sum of health scores between indices l and r (inclusive). Formally, the answer is \(\sum_{i=l}^{r} a_i\).

Your task is to process a series of these operations and output the results of each range sum query.

inputFormat

The first line contains an integer n, representing the number of trees. The second line contains n space-separated integers, representing the initial health scores of the trees. The third line contains an integer q, representing the number of queries/operations. The following q lines each contain an operation in one of the following formats:

1 x y - Update the x-th tree's health to y (1-indexed). 2 l r - Query the sum of health scores from the l-th to r-th tree (1-indexed).

outputFormat

For each range sum query (operation type 2), output the result on a new line.## sample

5
3 8 5 6 1
4
2 1 3
1 4 10
2 3 5
2 1 5
16

16 27

</p>