P1565 Cow Palace

Description

AP "Shenniu" plans to build a gorgeous rectangular palace on an $N \times M$ rectangular vacant lot. Each cell of the lot has an elevation $a_{i,j}$. AP wants the average elevation of his palace to be above sea level (assume sea level has height $0$). He also wants the palace to be as large as possible to accommodate more people to worship him. The palace must occupy a contiguous axis-aligned rectangle of cells. What is the maximum possible area of the palace?

Input Format

The first line contains $N$ and $M$. Then follow $N$ lines, each containing $M$ numbers, describing the elevations $a_{i,j}$.

Output Format

Output the maximum area of the palace.

Explanation/Hint

For $50\%$ of the testdata, $N,M \le 100$. For $100\%$ of the testdata, $1 \le N,M \le 200$, $-2\times10^9 \le a_{i,j} \le 16315$. Translated by ChatGPT 5