Route 2
Very easy
Execution time limit is 1 second
Runtime memory usage limit is 128 megabytes
Given a matrix , filled with positive integers. The path starts in the upper left corner of the matrix. In one move you can go into the next vertical or horizontal cell (if it exists). You can not walk diagonally, you can not stay in one place. Find the maximum sum of numbers, standing in the cells on the path of length (a cell can be visited several times).
Input
In the first row the integers and , separated with a space, are given. Each of the next rows contains numbers and describe the matrix. All numbers in matrix are integer and lie in the range from to .
Output
Print one number - the maximum sum.
Examples
Input #1
Answer #1
Submissions 1K
Acceptance rate 29%