beats 100%
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:o(nlgn)\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:o(n)\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nclass Solution {\npublic:\n    int maxProfitAssignment(vector<int>& d, vector<int>& p, vector<int>& w) {\n        int i,j=0,k=0,n=p.size();\n        vector<pair<int,int>>v;\n        for(i=0;i<n;i++)\n        {\n            v.push_back({d[i],p[i]});\n        }\n        sort(v.begin(),v.end());\n        j=0;\n        priority_queue<int>pq;\n        sort(w.begin(),w.end());\n        for(i=0;i<w.size();i++)\n        {\n           while(j<n)\n           {\n             if(v[j].first>w[i])\n             {\n                break;\n             }\n             pq.push(v[j].second);\n             j++;\n           }\n           if(j>0)k+=pq.top();\n        }\n        return k;\n    }\n};\n\n\n```\n![image.png](https://assets.leetcode.com/users/images/b72eb458-9686-4fd1-907d-7d7c44d26880_1718686075.3761146.png)\n
['Sorting', 'Heap (Priority Queue)', 'C++']