The Widest Container
Choose two walls; the water they hold is (distance) × (shorter wall's height). Print the maximum over all pairs.
Input: the first line has N (N ≥ 2); the second line has N non-negative heights.
Output: the maximum container capacity.
Constraints:
- 2 ≤ N ≤ 105
- 0 ≤ hi ≤ 109
Sample Tests
Input 1
9 1 8 6 2 5 4 8 3 7
Output 1
49
Input 2
2 1 1
Output 2
1
Discussion (opens after you solve — no spoilers before)
No comments yet.