Loading [MathJax]/jax/output/CommonHTML/jax.js
Peak Product - MarisaOJ: Marisa Online Judge

Peak Product

Time limit: 1000 ms
Memory limit: 256 MB
Consider an array A consisting of n integers. We define the function f(l,r) as follows: f(l,r)=(r−l+1)×min(Al,Al+1,...,Ar) Our goal is to find the maximum value of f(l,r) with 1≤l≤r≤n. ### Input - The first line contains an integer n. - The second line contains n integers Ai. ### Output - Print an integer is the maximum possible f(l,r). ### Constraints - 1≤n≤105. - 1≤Ai≤109. ### Example Input: 3123 Output: 4