Bitmask || Binary Search || Upper_bound || Take - Not take
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    int dp[101][1<<11];\n    int f(int i, int mask, vector<pair<int, int>>& vp) {\n        if (i == vp.size()) {\n            return 0;\n        }\n        // int ans=0;\n        if(dp[i][mask]!=-1){\n            return dp[i][mask];\n        }\n        int a = f(i + 1, mask, vp);\n        int ind = vp[i].second;\n        int num = vp[i].first;\n        int b = 0;\n        if (((mask >> ind) & 1) == 0) {\n            int z = upper_bound(\n                        vp.begin(), vp.end(), vp[i],\n                        [](const pair<int, int>& a, const pair<int, int>& b) {\n                            return a.first < b.first;\n                        }) -\n                    vp.begin();\n            b = num + f(z, mask | (1 << ind), vp);\n        }\n        return dp[i][mask]=max(a, b);\n    }\n    int maxScore(vector<vector<int>>& grid) {\n        vector<pair<int, int>> vp;\n        for (int i = 0; i < grid.size(); i++) {\n            for (int j = 0; j < grid[i].size(); j++) {\n                vp.push_back({grid[i][j], i});\n            }\n        }\n        sort(vp.begin(), vp.end());\n        //  for(aut)\n        memset(dp,-1,sizeof(dp));\n        return f(0, 0, vp);\n    }\n};\n```
['Array', 'Binary Search', 'Dynamic Programming', 'Bit Manipulation', 'Matrix', 'Bitmask', 'C++']