[C++] Dynamic Programming
Code
# Code
```cpp []
class Solution {
public:
    int maxScore(vector<vector<int>>& grid) {
        int m = grid.size();
        int n = grid[0].size();
        int max_score = INT_MIN;
        vector<vector<int>> dp(m + 1, vector<int>(n + 1, INT_MAX));
        for (int i = 0; i < m; i++) {
            for (int j = 0; j < n; j++) {
                dp[i + 1][j + 1] = min(min(dp[i][j + 1], dp[i + 1][j]), min(i > 0 ? grid[i - 1][j] : INT_MAX, j > 0 ? grid[i][j - 1] : INT_MAX));
                max_score = max(max_score, grid[i][j] - dp[i + 1][j + 1]);
            }
        }
        return max_score;
    }
};
```
['Dynamic Programming', 'C++']