L-Board

아직 제출이 없습니다시간 제한2초메모리 제한1024 MB

문제

Lord Pooty has a nn by mm board of integers AA and would like to draw an L. However, he would like to maximise the sum of integers on the tiles covered by L. The L can be rotated in all 4 possible orientations such that the sides are parallel to the board. Each side of the L may not necessarily be drawn (a straight line is possible). Some examples of valid Ls are shown below:

Formally, you want to choose 33 points, (x_1,y_1)(x\_1, y\_1), (x_2,y_1)(x\_2, y\_1) and (x_1,y_2)(x\_1, y\_2) (which may not necessarily be distinct) on the board AA such that

V=_i=min(x_1,x_2)max(x_1,x_2)A_i,y_1+_j=min(y_1,y_2)max(y_1,y_2)A_x_1,jA_x_1,y_1V = \sum\_{i = \min{(x\_1, x\_2)}}^{\max{(x\_1, x\_2)}}{A\_{i,y\_1}} + \sum\_{j = \min{(y\_1, y\_2)}}^{\max{(y\_1, y\_2)}}{A\_{x\_1,j}} - A\_{x\_1, y\_1}

is maximised.

입력

Your program must read from standard input.

The input starts with a line with two integers nn and mm where nn and mm are height and width of the board. This is followed by nn lines of mm integers, representing the board.

출력

Your program must print to standard output.

The output should contain a single integer on a single line, the maximum VV possible.

제한

  • 1n,m10001 ≤ n, m ≤ 1000
  • 109A_i,j109-10^9 ≤ A\_{i,j} ≤ 10^9 for 1in1 ≤ i ≤ n and 1jm1 ≤ j ≤ m