#P12241. Maximum Subarray Minimum Product
Maximum Subarray Minimum Product
Maximum Subarray Minimum Product
You are given a sequence of n
integers A1, A2, ..., An. Your task is to choose a contiguous subsequence defined by indices L
and R
(1-indexed) such that the value
\((R - L + 1) \times \min(A_L, A_{L+1}, \ldots, A_R)\)
is maximized. Note that you only need to output the maximum value, not the indices L
and R
.
Input Format: The first line contains an integer n
, representing the number of elements. The second line contains n
space-separated integers representing the sequence.
Output Format: Output a single integer that is the maximum product of the length of the subarray and the minimum value within that subarray.
inputFormat
The input consists of two lines:
- The first line contains an integer
n
(1 ≤ n ≤ 105). - The second line contains
n
space-separated integers, each representing an element in the sequence.
outputFormat
Output a single integer representing the maximum value of \((R - L + 1) \times \min(A_L, A_{L+1}, \ldots, A_R)\).
sample
7
2 1 4 5 1 3 3
8