Two Choice DP
State (i, j) means being in city j on day i\n# Code\ncpp []\nclass Solution {\npublic:\n    int maxScore(int n, int k, vector<vector<int>>& stayScore, vector<ve
State (i, j) means being in city j on day i\n# Code\n```cpp []\nclass Solution {\npublic:\n    int maxScore(int n, int k, vector<vector<int>>& stayScore, vector<vector<int>>& travelScore) {\n        vector<vector<int>> dp(k, vector<int>(n, 0));\n\n        for (int i = 0; i < k; i++){\n            for (int j = 0; j < n; j++){\n                // Stay in city j\n                if (i == 0){\n                    dp[i][j] = max(dp[i][j], stayScore[i][j]);\n                }\n\n                else{\n                    dp[i][j] = max(dp[i][j], dp[i - 1][j] + stayScore[i][j]);\n                }\n\n                // Travel from another city on day i - 1 to city j\n                if (i == 0){\n                    for (int first = 0; first < n; first++){\n                        dp[i][j] = max(dp[i][j], travelScore[first][j]);   \n                    }\n                }\n\n                else{\n                    for (int first = 0; first < n; first++){\n                        dp[i][j] = max(dp[i][j], dp[i-1][first] + travelScore[first][j]);   \n                    }\n                }\n            }\n        }\n\n        int res = -1;\n        for (int i = 0; i < n; i++){\n            res = max(res, dp[k - 1][i]);\n        }\n\n        return res;\n    }\n};\n```
[]