Simple Java Solution DP - (Memo)
Code\njava []\nclass Solution {\n    private int[][] ss;\n    private int[][] ts;\n    private int n;\n    private int k;\n\n    private int rec(int curCity, in
# Code\n```java []\nclass Solution {\n    private int[][] ss;\n    private int[][] ts;\n    private int n;\n    private int k;\n\n    private int rec(int curCity, int day, int dp[][]) {\n        if (day >= k)\n            return 0;\n        if (dp[curCity][day] != -1)\n            return dp[curCity][day];\n        int stay = ss[day][curCity] + rec(curCity, day + 1, dp);\n        int move = 0;\n        for (int i = 0; i < n; i++) {\n            if (i != curCity)\n                move = Math.max(move, ts[curCity][i]\n                        + rec(i, day + 1, dp));\n        }\n        return dp[curCity][day] = Math.max(stay, move);\n    }\n\n    public int maxScore(int n, int k, int[][] ss, int[][] ts) {\n        this.n = n;\n        this.k = k;\n        this.ss = ss;\n        this.ts = ts;\n        int res = 0;\n        int dp[][] = new int[n][k];\n        for (int[] d : dp)\n            Arrays.fill(d, -1);\n        for (int i = 0; i < n; i++) {\n            res = Math.max(res, rec(i, 0, dp));\n        }\n        return res;\n    }\n}\n```
[]