AtCoder Beginner Contest 189
翻译中…
Problem Statement
翻译中…
There are $N$ dishes arranged in a row in front of Takahashi. The $i$-th dish from the left has $A_i$ oranges on it.
翻译中…
Takahashi will choose a triple of integers $(l, r, x)$ satisfying all of the following conditions:
翻译中…
$1\leq l \leq r \leq N$;$1 \le x$;- for every integer
$i$between$l$and$r$(inclusive),$x \le A_i$.
翻译中…
He will then pick up and eat $x$ oranges from each of the $l$-th through $r$-th dishes from the left.
翻译中…
At most how many oranges can he eat by choosing the triple $(l, r, x)$ to maximize this number?
翻译中…
Constraints
翻译中…
- All values in input are integers.
$1 \leq N \leq 10^4$$1 \leq A_i \leq 10^5$
翻译中…
Input
翻译中…
Input is given from Standard Input in the following format:
翻译中…
N
A_1 \ldots A_N
翻译中…
Output
翻译中…
Print the maximum number of oranges Takahashi can eat.
翻译中…
样例
Input #1
6
2 4 4 9 4 9
Output #1
20
By choosing $(l,r,x)=(2,6,4)$, he can eat $20$ oranges.
Input #2
6
200 4 4 9 4 9
Output #2
200
By choosing $(l,r,x)=(1,1,200)$, he can eat $200$ oranges.
题目信息
题面与样例版权归 AtCoder 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。