100 atcoder#ABC186B. [ABC186B] Blocks on Grid
[ABC186B] Blocks on Grid
Score : points
Problem Statement
We have a grid with horizontal rows and vertical columns. The square at the -th row from the top and -th column from the left has blocks stacked on it.
At least how many blocks must be removed to make all squares have the same number of blocks?
Constraints
Input
Input is given from Standard Input in the following format:
Output
Print the minimum number of blocks that must be removed.
2 3
2 2 3
3 2 2
2
Removing block from the top-right square and from the bottom-left square makes all squares have blocks.
3 3
99 99 99
99 0 99
99 99 99
792
3 2
4 4
4 4
4 4
0