VisaOA #15
Largest Square Area in Cityscape
估计中等可在线判题
You are given an array of non-negative building heights. Find the largest area of a square that fits beneath a contiguous run of buildings; side s is feasible if and only if there are s consecutive buildings each with height at least s. This criterion corresponds to the explicit condition in the source's solution section.
输入格式
n (1≤n≤200000), n heights h (0≤h≤10^9); the ranges are site-added.
输出格式
Output the largest square area.
样例 1
输入:
5
1 2 3 2 1
输出:
4
样例 2
输入:
2
0 0
输出:
0
样例 3
输入:
3
3 3 3
输出:
9