gg
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time 
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```cpp []\n#pragma GCC optimize("unroll-loops,O3,Ofast")\n#pragma GCC target("avx2,avx,fma,bmi,bmi2,lzcnt,popcnt")\n#include <bits/stdc++.h>\n#define re return\n#define ff first\n#define ss second\n#define pb push_back\n#define gcd __gcd\n#define maxheap priority_queue<ll> // max heap\n#define minheap priority_queue<ll, vector<ll>, greater<ll>>\n#define pii pair<int, int>\n#define pll pair<ll, ll>\n#define lb *lower_bound\n#define up *upper_bound\n#define endl "\\n"\n#define all(x) (x).begin(), (x).end()\n#define allr(x) (x).rbegin(), (x).rend()\n#define INF LONG_LONG_MAX\n#define PI 3.141592653589793238462\n#define sz(x) ((ll)(x).size())\n#define rev(a) reverse(all(a))\nusing ll = long long;\nusing ull = unsigned long long;\nusing lld = long double;\n// Practice Till Death\n// Always Pass things by reference in dp\n// Always memoisation is not easy\n// Read Question twice\nusing namespace std;\nclass Solution {\npublic:\n    ll N;\n    int dp[201][201];\n    ll solve(ll city, ll day, ll k, vector<vector<int>>& s, vector<vector<int>>& t)\n    {\n        if(day == k)\n        return 0;\n\n        if(~dp[city][day])\n        return dp[city][day];\n\n        ll w1 = s[day][city] + solve(city, day + 1, k, s, t);\n        ll w2 = -INF;\n\n        for(int d = 0; d < N; d++)\n        {\n            ll val = t[city][d];\n            if(city == d)\n            val = 0;\n            w2 = max(w2,val + solve(d,day + 1, k, s, t));\n        }\n\n        return dp[city][day] = max(w2,w1);\n    }\n\n    int maxScore(int n, int k, vector<vector<int>>& s, vector<vector<int>>& t) {\n        memset(dp,-1,sizeof(dp));\n        N = n;\n        ll ans = -INF;\n        for(int i = 0; i < n; i++)\n        ans = max(ans,solve(i,0,k,s,t));\n        return ans;\n    }\n};\n```
[]