simple bitmask dp
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 []\nclass Solution {\npublic:\n\nint n,m;\nint dp[104][1025];\nint f(vector<vector<int>>&a,int r,int curr){\n    if(r==101) return 0;\n    if(dp[r][curr]!=-1) return dp[r][curr];\n    int ans=0;\n  ans=max(ans,f(a,r+1,curr));\n    for(auto x : a[r]){\n        if((curr>>x)&1) continue;\n        ans=max(ans,r+f(a,r+1,curr|(1<<x)));\n\n    }\n    return dp[r][curr]=ans;\n\n}\n\n    int maxScore(vector<vector<int>>& g) {\n        n=g.size();\n        m=g[0].size();\n       memset(dp,-1,sizeof(dp));\n       vector<vector<int>>a(101);\n       for(int i=0;i<n;i++){\n        for(int j=0;j<m;j++){\n            a[g[i][j]].push_back(i);\n        }\n       }\n        return f(a,1,0);\n        \n    }\n};\n```
['C++']