7026.Advertisement

Time Limit: 1s Memory Limit: 512MB

A fence consists of $n$ vertical boards. The width of each board is 1 and their heights may vary.

You want to attach a rectangular advertisement to the fence. What is the maximum area of such an advertisement?

Input Format(From the terminal/stdin)

The first input line contains an integer $n$ : the width of the fence.

After this, there are $n$ integers $k_1,k_2,\ldots,k_n$ : the height of each board.

  • $1 \le n \le 2 \cdot 10^5$
  • $1 \le k_i \le 10^9$

Output Format(To the terminal/stdout)

Print one integer: the maximum area of an advertisement.

Sample Input

Copy
8
4 1 5 3 3 2 4 1
 \n
 · · · · · · · \n

Sample Output

Copy
10
  \n
Source: CSES, Additional Problems I, 1142

Submit

请先 登录

© 2025 FAQs