lovely_anna
this isn\'t dynamic programming, this is just recursion and memoization\njavascript\nvar maxScore = function(n, k, a, b) {\n          // new Array(200).fill().m
this isn\'t dynamic programming, this is just recursion and memoization\n```javascript\nvar maxScore = function(n, k, a, b) {\n          // new Array(200).fill().map(() => Array(200).fill(-1))\n    let dp = Array.from({ length: k }, () => new Array(n).fill(-1))\n\n    let recu = (d, i) => {\n        if (d === k)\n            return 0\n        if (d !== -1 && dp.at(d).at(i) !== -1)\n            return dp.at(d).at(i)\n\n        let ans = 0\n        if (d === -1) {\n            for (let j = 0; j < n; j++)\n                ans = Math.max(ans, recu(0, j))\n        }\n        else {\n            for (let j = 0; j < n; j++) {\n                if (j === i)\n                    ans = Math.max(ans, a.at(d).at(i) + recu(d + 1, i))\n                else\n                    ans = Math.max(ans, b.at(i).at(j) + recu(d + 1, j))\n            }\n        }\n\n        if (d === -1)\n            return ans\n        return dp[d][i] = ans\n    }\n\n    return recu(-1)\n}\n```\n# lovely_anna\n### (a javascript lover)
[]