아직 만들고 있는 페이지입니다.

이 페이지는 아직 만드는 중입니다. 보이는 내용은 바뀔 수 있습니다.

L-Board

시간 제한2초메모리 제한1024 MB

요약
n x m 정수 판에서 한 모서리를 공유하는 두 선분으로 이루어진 L 모양을 골라 덮는 칸의 합을 최대로 만든다.
난이도

보통10점 중 6점

유형
누적 합, 구현, 수학
정답자
아직 제출이 없습니다

문제

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,j−A_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.

제한

  • 1≤n,m≤10001 ≤ n, m ≤ 1000
  • −109≤A_i,j≤109-10^9 ≤ A\_{i,j} ≤ 10^9 for 1≤i≤n1 ≤ i ≤ n and 1≤j≤m1 ≤ j ≤ m

예제2

  1. 예제 1

    입력
    2 2
    8 1
    3 4
    
    예상 출력
    15
    
  2. 예제 2

    입력
    1 8
    -2 -1 8 -2 9 0 -2 1
    
    예상 출력
    15