#t361. 最佳旅游线路

最佳旅游线路

Best Tour Route

Problem Description

The streets of a tourist area form a grid. The east-west streets are all tourist streets, and the north-south streets are all tree-lined avenues. Because of the many tourists, the tourist streets are designated as one-way streets: tourists may only walk from west to east on a tourist street, but on a tree-lined avenue they may walk either from south to north or from north to south.

Along wants to visit this tourist street. His friend Afu gave him some advice, using scores to indicate how worthwhile each segment between two adjacent intersections on the tourist streets is to visit. The scores are integers from −100-100 to 100100; the tree-lined avenues are not scored. It is not possible for all scores to be negative. See the figure:

Input Format

The first line of input contains two integers mm and nn separated by a space, where mm is the number of tourist streets (1≤m≤100)(1 \le m \le 100) and nn is the number of tree-lined avenues (1≤n≤20001)(1 \le n \le 20001). The following mm lines give the score information of each tourist street from north to south in order. Each line has nn integers, giving the scores of each small segment of the tourist street from west to east in order, separated by a space.

Output Format

Output a single line, an integer, the total score of the best tour route your program finds.

Sample Input

3 5
-50 -47 36 -30 -23
17 -19 -34 -13 -8
-42 -3 -43 34 -45

Sample Output

84

Constraints

Time limit: 1s, memory limit: 1024KiB for each test case.