C++ DP Memo 
We use x and y and rem as our parameters. Since rem can only be 2, our overall complexity will not exceed O(n*m)TIME COMPLEXITY: O(n*m)Code
We use x and y and rem as our parameters. Since rem can only be 2, our overall complexity will not exceed O(n*m)


TIME COMPLEXITY: O(n*m)

# Code
```cpp []
class Solution {
public:

    int recur(vector<vector<int>>& coins, int x, int y, int remain,vector<vector<vector<int>>>& dp) {
        if (x==coins.size()-1&&y==coins[x].size()-1) {

            if (coins[x][y]<0&&remain>0) {
                return 0;
            }
            
            return coins[x][y];
        }

        if (x<0||y<0||x>=coins.size()||y>=coins[x].size()) {
            return -INT_MAX+10000;
        }

        if (dp[x][y][remain]!=-1) {
            return dp[x][y][remain];
        }

        int use = -INT_MAX+10000;
        int lose = -INT_MAX+10000;

        if (coins[x][y]<0&&remain>0) {
            use = max(recur(coins,x+1,y,remain-1,dp),recur(coins,x,y+1,remain-1,dp));
        } 

        lose = max(recur(coins,x+1,y,remain,dp)+coins[x][y],recur(coins,x,y+1,remain,dp)+coins[x][y]);

        return dp[x][y][remain]=max(use,lose);
    }

    int maximumAmount(vector<vector<int>>& coins) {
        vector<vector<vector<int>>> dp(coins.size()+1,vector<vector<int>>(coins[0].size()+1,vector<int>(3,-1)));
        
        return recur(coins,0,0,2,dp);
    }
};
```
['Dynamic Programming', 'Memoization', 'C++']