#K75087. Process Transactions

    ID: 34341 Type: Default 1000ms 256MiB

Process Transactions

Process Transactions

In this problem, you are given an array of stock prices over \(n\) days and \(m\) operations. Each operation is either an update or a query. For an update, you are given an operation in the form 1 x v, which updates the price on day \(x\) to \(v\). For a query, you are given an operation in the form 2 x y, and you need to output the maximum stock price in the range [\(x\), \(y\)], i.e., compute \(\max_{x \le i \le y} a_i\). The operations must be processed in order, and your solution should read from standard input (stdin) and write the output to standard output (stdout).

inputFormat

The first line contains two integers \(n\) and \(m\), representing the number of days and the number of operations, respectively. The second line contains \(n\) space-separated integers representing the initial stock prices. Each of the following \(m\) lines contains an operation:

  • 1 x v: Update the price on day \(x\) to \(v\).
  • 2 x y: Query for the maximum price from day \(x\) to day \(y\) (inclusive).

outputFormat

For each query of type 2, output a single line containing the maximum stock price within the given range. If there are no queries of type 2, output nothing.

## sample
6 5
100 200 150 170 180 110
2 2 4
1 5 130
2 1 5
1 4 220
2 3 6
200

200 220

</p>