P6063 [USACO05JAN] The Wedding Juicer G

Description

John’s cows found a nice part-time job: designing a punch-style juicer. The juicer is designed as follows. There is a base of size $W \times H$ ($3 \leq W,H \leq 300$). On each $1 \times 1$ cell, there is a pillar of height $B$ ($1 \leq B \leq 10^9$) used for juicing. Assume that the pillars are perfectly glued together, so water will not leak through the gaps between pillars. However, John has never known how much juice such a juicer can hold. Assume there is nothing around the juicer, which means water on the boundary will flow away. Some juicers cannot hold any juice at all.

Input Format

The first line contains two integers $W$ and $H$. The next $H$ lines each contain $W$ numbers, representing the heights.

Output Format

Output the maximum amount of juice it can hold.

Explanation/Hint

Translated by ChatGPT 5