时间限制:C/C++/Rust/Pascal 6秒,其他语言12秒
空间限制:C/C++/Rust/Pascal 512 M,其他语言1024 M
64bit IO Format: %lld
题目描述
Given a

grid, with each point having a value

(coordinate is from

).
Now you need to select

points, one of which is considered as a good point
![[i, j]](https://www.nowcoder.com/equation?tex=%5Bi%2C%20j%5D)
if it satisfy one of the conditions. Otherwise, it's a bad point.

and
![\ \ [i -1,\ j - 1]](https://www.nowcoder.com/equation?tex=%5C%20%5C%20%5Bi%20-1%2C%5C%20%20j%20%20-%20%201%5D)
and
![[i -1, \ j + 1]](https://www.nowcoder.com/equation?tex=%5Bi%20-1%2C%20%5C%20j%20%20%2B%201%5D)
are both selected
A selection is legal if and only if the number of bad points is less than or equal to

.
For

, print the maximum value of the sum of all the points selected.
If there is no solution, output

.
输入描述:
The first line contains two integers
(
).
The next
lines contains
space separated integers
(
) representing the values of each cell of the grid.
输出描述:
The output contains
lines.
The
-th line represents the answer when
.
示例2
输入
复制
4 0
2 1 0 8
0 10 1 0
0 0 0 0
0 0 0 0
输出
复制
8
10
12
20
21
22
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1