Solution
C++ []\nclass Solution {\npublic:\n    int maxProfitAssignment(vector<int>& difficulty, vector<int>& profit, vector<int>& worker) {\n        int n = profit.size
```C++ []\nclass Solution {\npublic:\n    int maxProfitAssignment(vector<int>& difficulty, vector<int>& profit, vector<int>& worker) {\n        int n = profit.size(), res = 0, l = 0, p = 0;\n        vector<pair<int, int>> pairs;\n        for(int i = 0; i < n; i++) pairs.emplace_back(difficulty[i], profit[i]);\n        sort(pairs.begin(), pairs.end());\n        sort(worker.begin(), worker.end());\n        for(int &w: worker){\n            while(l < n && w >= pairs[l].first){\n                p = max(p, pairs[l++].second);\n            }\n            res += p;\n        }\n        return res;\n    }\n};\n```\n\n```Python3 []\nclass Solution:\n    def maxProfitAssignment(self, difficulty: List[int], profit: List[int], worker: List[int]) -> int:\n        jobs = sorted(zip(profit, difficulty), reverse=True)\n        worker.sort()\n        total_profit = 0\n\n        for prof, diff in jobs:\n            while worker and diff <= worker[-1]:\n                total_profit += prof\n                worker.pop()\n            if not worker:\n                break\n\n        return total_profit\n```\n\n```Java []\nclass Solution {\n    public int maxProfitAssignment(int[] difficulty, int[] profit, int[] worker) {\n        int max=0;\n        for(int d:difficulty)\n            max = Math.max(max, d);\n        int[] dp = new int[max+1];\n        for(int i=0;i<difficulty.length;i++) \n            dp[difficulty[i]] = Math.max(dp[difficulty[i]], profit[i]);\n        for(int i=1;i<=max;i++)\n            dp[i] = Math.max(dp[i-1], dp[i]);\n        int ans=0;\n        for(int w:worker)\n        {\n            if(w>max) ans+=dp[max];\n            else ans+=dp[w];\n        }\n        return ans;\n    }\n}\n```\n
['C++', 'Java', 'Python3']