#K75297. Maximum Water Container
Maximum Water Container
Maximum Water Container
Given n vertical lines on a coordinate plane, where the i-th line has a positive height height[i], find two lines such that together with the x-axis they form a container that holds the maximum amount of water.
The area of water that can be contained is given by the formula:
\( \text{Area} = \min(\text{height}[i],\,\text{height}[j]) \times (j-i) \)
Your task is to compute the maximum area of water a container can store. You may not tilt the container.
inputFormat
The input is read from standard input (stdin) and has the following format:
- The first line contains an integer n (\( n \ge 2 \)) representing the number of vertical lines.
- The second line contains n space-separated positive integers representing the heights of the lines.
outputFormat
Output a single integer representing the maximum amount of water the container can hold. The output is written to standard output (stdout).
## sample9
1 8 6 2 5 4 8 3 7
49