#K73342. Taco Sequence Queries

    ID: 33954 Type: Default 1000ms 256MiB

Taco Sequence Queries

Taco Sequence Queries

You are given a sequence of n integers. You need to process q queries on this sequence. There are two types of queries:

  • Update Query: "1 i x". Update the element at the position i (1-indexed) to the value x.
  • Sum Query: "2 l r". Compute the sum of elements from position l to r (both inclusive).

Input/Output Format:

The input is read from stdin and the output should be printed to stdout.

Note: All indices in the queries are 1-indexed.

Mathematically, for a sum query, you are to compute \[ S = \sum_{k=l}^{r} a_k \] where \(a_k\) represents the kth element of the sequence.

inputFormat

The first line contains two integers n and q representing the number of elements in the sequence and the number of queries, respectively.

The second line contains n space-separated integers representing the initial sequence.

The following q lines each contain a query in one of the following formats:

  • 1 i x — update the element at index i to x.
  • 2 l r — output the sum of the elements from index l to r (inclusive).
  • </p>

    outputFormat

    For each query of type 2, output the computed sum on a new line to stdout.

    ## sample
    6 3
    1 2 3 4 5 6
    2 1 3
    1 3 10
    2 2 5
    6
    

    21

    </p>