import java.util.*; public class Bonus { public int getMost(int[][] board) { // write code here int row = board.length; int[][] dp = new int[row][row]; dp[0][0] = board[0][0]; for (int i = 1; i < row; i++) { dp[i][0] = dp[i - 1][0] + board[i][0]; dp[0][i] = dp[0][i - 1] + board[0][i]; } for (int i = 1; i < row; i++) { for (int j = 1; j < row ; j++) { dp[i][j] = Math.max(dp[i][j - 1], dp[i - 1][j]) + board[i][j]; } } return dp[row - 1][row - 1]; } }