#K51302. Cluster Resource Management

    ID: 29057 Type: Default 1000ms 256MiB

Cluster Resource Management

Cluster Resource Management

You are in charge of managing resource allocation for a computer cluster. The cluster consists of N nodes, where each node has a certain amount of available resources. Your task is to process a series of operations to update the available resources of specific nodes or query the maximum resource value among a range of nodes.

There are two types of operations:

  • Update Operation: Given in the format 1 x r, it updates the resource at the x-th node to r.
  • Query Operation: Given in the format 2 x y, it queries and returns the maximum resource among nodes from x to y (inclusive).

Nodes are numbered starting from 1. The solutions may require efficient query and update operations, so using data structures such as a segment tree is recommended.

Note: If a test case does not contain any query operations, you should output nothing for that case.

inputFormat

The input is read from stdin and is structured as follows:

  1. The first line contains an integer T, the number of test cases.
  2. For each test case:
    1. The first line contains an integer N: the number of nodes in the cluster.
    2. The second line contains N space-separated integers, each representing the available resources at each node.
    3. The third line contains an integer Q: the number of operations to perform.
    4. The next Q lines each describe an operation in one of the following formats:
      • 1 x r for an update operation (set the resource at node x to r).
      • 2 x y for a query operation (find the maximum resource in the node range x to y inclusive).

outputFormat

The output should be written to stdout. For each query operation (type 2), print the result on a new line. If a test case contains no query operations, do not output anything for that test case.

## sample
2
3
10 20 15
3
2 1 3
1 2 5
2 2 3
4
5 8 10 6
2
2 1 3
1 3 12
20

15 10

</p>