✅ Java Solution
CODE\nJava []\nclass Solution {\n    int res;\n    private void solve(List<List<Integer>> grid, int i, int total, boolean[] vis, int size) {\n        if(total +
## **CODE**\n```Java []\nclass Solution {\n    int res;\n    private void solve(List<List<Integer>> grid, int i, int total, boolean[] vis, int size) {\n        if(total + (size - i) * (200 - (size - i - 1)) / 2 < res) return;\n        \n        if(i == size) {\n            res = Math.max(res, total);\n            return;\n        }\n        boolean flag = false;\n        for(int val : grid.get(i)) {\n            if(!vis[val]) {\n                vis[val] = true;\n                solve(grid, i+1, total+val, vis, size);\n                vis[val] = false;\n                flag = true;\n            }\n        }\n        if(!flag) {\n            solve(grid, i+1, total, vis, size);\n        }\n    }\n    public int maxScore(List<List<Integer>> grid) {\n        res = 0;\n        for(List<Integer> list : grid) {\n            Collections.sort(list, Collections.reverseOrder());\n        }\n        boolean[] vis = new boolean[101];\n        solve(grid, 0, 0, vis, grid.size());\n        return res;\n    }\n}\n```
['Java']