#572. 「Nowcoder多校 2019 Day2」Inside A Rectangle

「Nowcoder多校 2019 Day2」Inside A Rectangle

当前没有测试数据。

题目描述

Given N×MN \times M grid, each cell has a value aija_{ij}​, you can choose at most two rectangles such that sum of values of the cell belonging to exactly\textbf{exactly} one rectangle is maximized.

A rectangle can be defined as four integers x1,y1,x2,y2x_1, y_1, x_2, y_2​ where 1x1x2N1 \leq x_1 \leq x_2 \leq Nand 1y1y2M1 \leq y_1 \leq y_2 \leq M. Then, the rectangle is composed of all the cell (x, y) where x1xx2x_1 \leq x \leq x_2 and y1yy2y_1 \leq y \leq y2.

After choosing the rectangles, the resulting value will be the sum of values of the cell belonging to exactly\textbf{exactly} one of them.

输入格式

The first line of input contains two space-separated integers N and M. Following N lines each contains M space-separated integers aija_{ij}.

输出格式

Output one line containing an integer representing the answer.

样例

样例输入 1

5 5
10 10 10 10 -1
10 -1 -1 -1 10
10 -1 -1 -1 10
10 -1 -1 -1 10
-1 10 10 10 10

样例输出 1

140

数据范围与提示

1N,M501 \leq N, M \leq 50

105aij105-10^5 \leq a_{ij} \leq 10^5