| Author: | Pavel Mesenev | Time limit: | 2 sec | |
| Input file: | Standard input | Memory limit: | 256 Mb | |
| Output file: | Standard output |
You are given n non-negative integers h0, h1, …, hn − 1, where hi is the height of a vertical line drawn at position i. Choose two lines i < j; together with the x-axis they form a container that can hold (j − i) ⋅ min(hi,hj) units of water. Find the maximum amount of water any pair of lines can hold.
The first line contains one integer n. The second line contains n space-separated integers h0… hn − 1.
Print one integer — the maximum water any pair of lines can hold.
2 ≤ n ≤ 2 ⋅ 105
0 ≤ hi ≤ 109
| No. | Standard input | Standard output |
|---|---|---|
| 1 |
|
|
| 2 |
|
|
| 3 |
|
|