403076: GYM100989 N Mixed Dimensions

Memory Limit:256 MB Time Limit:1 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

N. Mixed Dimensionstime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard output

Mixed Dimensions is an innovative company that is specialized in 3D printing technologies. They are planning to 3D print decorative tiles to be used in the beautiful pavements of Amman.

After printing thousands of these decorative tiles, Mixed Dimensions washed the tiles with water to make them look fresh before they are delivered. Unfortunately, water gathered inside some places in the decorations. Observing the problem, they decided to fill any cavity (hole) in the decorations so that no water gathers after a rainy day.

Given a 3D printed tile that represents a grid of size R×C, and the height in unit cubes above each point in the grid, your task is to compute the volume of printing material needed to fill the cavities (holes).

Two units3 of printing material are needed to fill this tile.

Input

The first line of input contains two integers R and C (1 ≤ R, C ≤ 500), the number of rows and columns of the base grid, respectively.

Each of the following R lines contains C integers, each integer is between 1 and 109 and represents the height in unit cubes above one of the cells.

Output

Print the volume of the printing material needed to fill the given tile so that no water gathers after a rainy day.

ExamplesInput
4 3
2 3 3
2 1 2
3 1 3
3 2 1
Output
2

加入题单

上一题 下一题 算法标签: