Question
The Kraken's Last Dam
A harbour engineer is designing a seawall. She has
Find the maximum water capacity any such pair of pillars can hold.
Input
The first line contains KaTeX can only parse string typed expression. The second line contains KaTeX can only parse string typed expression space-separated non-negative integers — the heights of the pillars.
Output
A single integer — the maximum water capacity.
Example
Example 1:
Input
Pillars at positions 1 and 8 (0-indexed) with heights 8 and 7 give capacity min(8,7) × 7 = 49.
Example 2:
Input
Input
9
1 8 6 2 5 4 8 3 7Output49ExplanationPillars at positions 1 and 8 (0-indexed) with heights 8 and 7 give capacity min(8,7) × 7 = 49.
Example 2:
Input
2
1 1Output1