eolymp
bolt
Try our new interface for solving problems
Problems

Container With Most Water

Container With Most Water

You are given an integer array $h$ of length $n$. There are $n$ vertical lines drawn such that the two endpoints of the $i$-th line are $(i, 0)$ and $(i, h[i])$. Find two lines that together with the $x$-axis form a container, such that the container contains the most water. \InputFile The first line contains the size $n~(n \le 10^5)$ of array $h$. Second line contains $n$ positive integers --- the elements of array $h$, that are no more than $10^9$. \OutputFile Print the maximum amount of water a container can store. \includegraphics{https://static.eolymp.com/content/33/333a6c825c6572669b0fc1daa1fb0987814c0943.gif}
Time limit 1 second
Memory limit 128 MiB
Input example #1
9
1 8 6 2 5 4 8 3 7
Output example #1
49