#C1943. Max Water Container
Max Water Container
Max Water Container
You are given n vertical lines together with their heights. The problem is to find the maximum area of water a container can store, which is formed by two lines and the x-axis. The area of the container is calculated using the formula:
\(\text{Area} = (j-i) \times \min(h_i, h_j)\)
where i and j represent the indices of the two lines with i < j and \(h_i\) and \(h_j\) are their respective heights. Your task is to compute the maximum area that can be contained by any two lines.
inputFormat
The input is read from standard input (stdin). The first line contains an integer n
, the number of vertical lines. The second line contains n
space-separated integers representing the heights of these lines.
outputFormat
Output a single integer to standard output (stdout) representing the maximum area of water that can be contained by the container formed by any two lines.## sample
9
1 8 6 2 5 4 8 3 7
49