AtCoder Beginner Contest 407(Promotion of AtCoderJobs)
翻译中…
Problem Statement
翻译中…
There is a grid with $H$ rows and $W$ columns. Let $(i,j)$ denote the cell at the $i$-th row from the top $(1\leq i\leq H)$ and the $j$-th column from the left $(1\leq j\leq W)$.
翻译中…
Cell $(i,j)\ (1\leq i\leq H,1\leq j\leq W)$ has an integer $A_{i,j}$ written on it.
翻译中…
Let us place zero or more dominoes on the grid. A domino covers two adjacent cells, namely one of the following pairs:
翻译中…
- cells
$(i,j)$and$(i,j+1)$for$1\leq i\leq H,1\leq j\lt W$; - cells
$(i,j)$and$(i+1,j)$for$1\leq i\lt H,1\leq j\leq W$.
翻译中…
No cell may be covered by more than one domino.
翻译中…
For a placement of dominoes, define its score as the sum of all integers written in cells not covered by any domino.
翻译中…
Find the maximum possible score.
翻译中…
Constraints
翻译中…
$1\leq H$$1\leq W$$HW\leq2000$$-10 ^ {12}\leq A _ {i,j}\leq10 ^ {12}\ (1\leq i\leq H,1\leq j\leq W)$- All input values are integers.
翻译中…
Input
翻译中…
The input is given from Standard Input in the following format:
翻译中…
H W
A _ {1,1} A _ {1,2} \ldots A _ {1,W}
A _ {2,1} A _ {2,2} \ldots A _ {2,W}
\vdots
A _ {H,1} A _ {H,2} \ldots A _ {H,W}
翻译中…
Output
翻译中…
Output the answer.
翻译中…
样例
Input #1
3 4
3 -1 -4 1
-5 9 -2 -6
-5 3 -5 8
Output #1
23
The grid is as follows:

For example, the placement below yields a score of $23$.

No placement achieves a score of $24$ or higher, so output `23`.
Input #2
5 5
-70 11 -45 -54 -30
-99 39 -83 -69 -77
-48 -21 -43 -96 -24
-54 -65 21 -88 -44
-90 -33 -67 -29 -62
Output #2
39
Input #3
8 9
-74832 16944 58683 32965 97236 -52995 43262 -51959 40883
-58715 13846 24919 65627 -11492 -63264 29966 -98452 -75577
40415 77202 15542 -50602 83295 85415 -35304 46520 -38742
37482 56721 -38521 63127 55608 95115 42893 10484 70510
53019 40623 25885 -10246 70973 32528 -33423 19322 52097
79880 74931 -58277 -33783 91022 -53003 11085 -65924 -63548
78622 -77307 81181 46875 -81091 63881 11160 -82217 -55492
62770 39530 -95923 92440 -69899 77737 89392 -14281 84899
Output #3
2232232
题目信息
题面与样例版权归 AtCoder 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。