#C950. Matrix Query Operations
Matrix Query Operations
Matrix Query Operations
You are given an (m \times n) matrix of integers and a sequence of queries. There are two types of queries:
- Increase x: Increase a cumulative increment by an integer (x).
- Maximum: Output the maximum element of the matrix plus the current cumulative increment.
Initially, the cumulative increment is (0). For each "Maximum" query, compute (\max(matrix) + increment) at that moment and output the result. Process the queries in the given order.
This problem tests your ability to process sequential commands and perform simple matrix operations.
inputFormat
The input is given from stdin in the following format:
- The first line contains two integers (m) and (n), representing the number of rows and columns of the matrix.
- The next (m) lines each contain (n) integers, representing the matrix rows.
- The following line contains an integer (Q), the number of queries.
- The next (Q) lines each contain a query in one of the following formats:
- "Increase x" (where (x) is an integer)
- "Maximum"
outputFormat
For each "Maximum" query, output the result on a separate line to stdout.## sample
3 3
1 2 3
4 5 6
7 8 9
4
Increase 5
Maximum
Increase -3
Maximum
14
11
</p>