L-Board | 프로그래밍의 벗 PivotOJ
PivotOJ

L-Board

시간 제한: 2000ms메모리 제한: 1024MB출처: NOI 2022 QualificationBOJ 27285
이 문제는 본문 이미지 일부가 표시되지 않습니다. 텍스트만으로 풀이가 어려울 수 있습니다.

문제

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:

[이미지 1]

Formally, you want to choose 33 points, (x1,y1)(x_1, y_1), (x2,y1)(x_2, y_1) and (x1,y2)(x_1, y_2) (which may not necessarily be distinct) on the board AA such that

V=i=min(x1,x2)max(x1,x2)Ai,y1+j=min(y1,y2)max(y1,y2)Ax1,jAx1,y1V = \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

입력
2 2
8 1
3 4
출력
15

예제 2

입력
1 8
-2 -1 8 -2 9 0 -2 1
출력
15
이 문제는 채점 준비 중입니다. 테스트 데이터가 확보되면 제출이 가능합니다.