#K51302. Cluster Resource Management
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:
- The first line contains an integer T, the number of test cases.
- For each test case:
- The first line contains an integer N: the number of nodes in the cluster.
- The second line contains N space-separated integers, each representing the available resources at each node.
- The third line contains an integer Q: the number of operations to perform.
- 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.
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>