1387: 取数

Memory Limit:128 MB Time Limit:1.000 S
Judge Style:Text Compare Creator:
Submit:1 Solved:1

Description

一个n*m大小的方格中(如图),从起点(0,0)出发,只能向下或是向右走,终点为(n,m)。设s为从起点到终点的路径上所有方格中的数字的和,求s的最大值?
                                                                                  

Input

第1行输入两个数n, m(1 <= n, m <= 100)
第2到n+1行每行输入m个数表示方格中每个格子上的数(每个格子中的数均不超过100)

Output

s的最大值

Sample Input Copy

4 6
6 36 35 5 18 29 
31 19 35 21 18 30 
26 16 26 24 8 27 
4 1 28 25 15 10 

Sample Output Copy

218

Source/Category