⭐ [C++] Straightforward Solution
Code\ncpp []\nclass Solution {\npublic:\n    vector<vector<int>> dp;\n    int n,k;\n\n    int solve (int day, int city, vector<vector<int>>& ss, vector<vector<i
# Code\n```cpp []\nclass Solution {\npublic:\n    vector<vector<int>> dp;\n    int n,k;\n\n    int solve (int day, int city, vector<vector<int>>& ss, vector<vector<int>>& ts) {\n        if (day==k) return 0;\n        if (dp[day][city]!=-1) return dp[day][city];\n        int ans = solve (day+1, city, ss, ts) + ss[day][city]; // stay in current city\n        for (int i=0; i<n; i++) {\n            ans = max (ans, solve(day+1, i, ss, ts) + ts[city][i]); // move to city \'i\'\n        }\n        return dp[day][city] = ans;\n    }\n\n    int maxScore(int n, int k, vector<vector<int>>& ss, vector<vector<int>>& ts) {\n        this->n=n; this->k=k;\n        dp.resize(k+1, vector<int> (n+1, -1));\n        int ans = -1;\n        for (int i=0; i<n; i++) ans = max (ans, solve(0,i,ss,ts)); //try all possible cities as first city\n        return ans;\n    }\n};\n```
[]