Priority Queue Approach
Intuition\nWe have to create a priority queue for each of the jobs because we only care about maximizing profit. By prioritizing completing the most profitable 
# Intuition\nWe have to create a priority queue for each of the jobs because we only care about maximizing profit. By prioritizing completing the most profitable jobs first and keeping the workers in sorted order, we can greedily obtain the maximum profit. \n\n# Approach\nWe will create a pair for each job, and the priority queue will first sort by profit and then by difficulty of the job. Then we will sort the workers vector. Since the workers vector is sorted, if we encounter a job that is too difficult for the current worker, we can simply pop that job off the pq because we know no other workers will be able to complete it. This will give us the maximum total profit in the end.\n\n# Complexity\n- Time complexity: O(mlogm + nlogn)\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\nCreating the priority queue requires iterating through m jobs and doing logm work for each job. Sorting a vector of size n requires nlogn work.\n\n- Space complexity: O(m)\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\nThe priority queue takes up m space, where m is the amount of jobs.\n\n# Code\n```\nclass Solution {\npublic:\n    int maxProfitAssignment(vector<int>& difficulty, vector<int>& profit, vector<int>& worker) {\n        std::priority_queue<std::pair<int, int>> pq;\n\n        for (int i = 0; i < difficulty.size(); ++i) {\n            int dif = difficulty[i];\n            int prof = profit[i];\n            std::pair<int, int> p = std::make_pair(prof, dif);\n\n            pq.push(p);\n        }\n\n        std::sort(worker.begin(), worker.end(), std::greater());\n        // std::reverse(worker.begin(), worker.end());\n\n        int maxProfit = 0;\n        for (int i = 0; i < worker.size(); ++i) {\n            int worker_difficulty = worker[i];\n\n            while (!pq.empty() && pq.top().second > worker_difficulty) {\n                pq.pop();\n            }\n\n            if (!pq.empty()) {\n                maxProfit += pq.top().first;\n            }\n            else {\n                return maxProfit;\n            }\n        }\n        return maxProfit;\n    }\n};\n```
['C++']