#P6063. Stamping Juicer
Stamping Juicer
Stamping Juicer
John's cows have found a nice side job: designing a stamping juicer. The juicer is built on a base of size $W \times H$ where $3\le W,H\le 300$. Each cell of the base contains a column of height $B$ (where $1\le B\le 10^9$) used for juicing. The columns are perfectly glued together so that no water can leak between them.
However, the juicer is open at the boundaries and any water at the edges will flow away. As such, the juicer might not be able to hold any juice at all. Your task is to determine the maximum amount of juice (modeled as water) that the juicer can hold.
Input Format
The first line contains two integers $W$ and $H$, representing the width and height of the base. Each of the next $H$ lines contains $W$ integers, where each integer $B$ indicates the height of the column at that cell.
Output Format
Output a single integer representing the total volume of water that can be held by the juicer.
Examples
Input:
3 3 3 3 3 3 1 3 3 3 3
Output:
2
Explanation: The only cell that can trap water is the center cell. Its water level can reach 3 (the minimum height among its surrounding cells), so it holds $3-1=2$ units of water.
inputFormat
The first line contains two integers $W$ and $H$, representing the dimensions of the base. The next $H$ lines each contain $W$ space-separated integers representing the column heights $B$.
outputFormat
Output a single integer representing the maximum volume of water (juice) that can be held by the juicer.
sample
3 3
3 3 3
3 1 3
3 3 3
2