#P8563. Maximum Subarray Product with Updates
Maximum Subarray Product with Updates
Maximum Subarray Product with Updates
You are given an integer sequence \(a\) of length \(n\) where for every element \(a_i\) it holds that \(|a_i| \ge 2\). You are also given \(q\) operations. Each operation is in one of the following two formats:
1 i k
: Update the \(i\)th element to \(k\) (it is guaranteed that \(|k| \ge 2\)).2 l r
: Consider all subarrays (contiguous intervals) within the segment \([l, r]\) (including \([l, r]\) itself). Let \(M\) be the maximum product among these subarrays. Note that the product of an empty subarray is defined as \(1\). If \(M > 2^{30}\), outputToo large
; otherwise, output \(M\).
It is guaranteed that the operations follow the above format.
Note: Subarray means a contiguous segment of the array.
inputFormat
The first line contains two integers \(n\) and \(q\), representing the length of the sequence and the number of operations.
The second line contains \(n\) space‐separated integers \(a_1, a_2, \dots, a_n\) with \(|a_i| \ge 2\).
The following \(q\) lines each describe an operation in one of the two formats:
1 i k
2 l r
outputFormat
For each operation of type 2
, output the answer on a new line. If the maximum subarray product \(M\) is greater than \(2^{30}\), output Too large
; otherwise output \(M\>.
sample
5 3
2 -2 3 -4 2
2 1 5
1 3 -2
2 2 4
96
8
</p>