public class DTGH_JuZhenShortRoad {
public int shortRoad(int[][] m){
int[][] dp=new int[m.length][m[0].length];
dp[0][0]=m[0][0];
for (int i = 1; i <m.length ; i++) {
dp[i][0]=dp[i-1][0]+m[i][0];
}
for (int i = 1; i <m[0].length ; i++) {
dp[0][i] = dp[0][i-1] + m[0][i];
}
for (int i = 1; i <m.length ; i++) {
for (int j = 0; j <m[0].length ; j++) {
dp[i][j]=Math.min(m[i-1][j],m[i][j-1]);
}
}
return dp[m.length-1][m[0].length-1];
}
}