#Y1012. 迷途
迷途
Background:
is very adored of orz
Problem Description:
and live in a point a11 and amn in a rectangular town of size m * n (ensuring that they are on the same diagonal). Because wants to ask and 's modem is broken, they have to go to . Because there are so many "good people" in the township, the has to pay the tolls. wants to know how many tolls it needs to pay.(The town map is shown in the figure below)
Taking the town as a real matrix Amn, aij represents the toll to be paid here to ensure satisfaction. Please ask the minimum amount of tolls for .(Note: can only move up, down, left and right)
Input Format:
The first row, two positive integers n, m, represent the size of the matrix.
The next n rows, m positive integers, represent the toll needs to pay at each node.(Note: The point where and are located is 0)
Output Format:
One line, a positive integer, represents the minimum toll required for .
Input / output sample:
Enter # 1:
3 3
0 7 2
5 4 7
6 8 0
output #1:
16
统计
相关
在下列比赛中: