Python - 2 lines DP
Code\n\n\nclass Solution:\n    def maxScore(self, n, k, ss, ts):        \n        @cache\n        def dp(city, d): return max(max([dp(to, d + 1) + cost for to, 
# Code\n```\n\nclass Solution:\n    def maxScore(self, n, k, ss, ts):        \n        @cache\n        def dp(city, d): return max(max([dp(to, d + 1) + cost for to, cost in enumerate(ts[city]) if to != city], default=0), dp(city, d + 1) + ss[d + 1][city]) if d + 1 < k else 0\n        return max(dp(i, -1) for i in range(n))\n        \n```
[]