✅C++ || Binary Search
Code\n\nclass Solution {\npublic:\n    int maxProfitAssignment(vector<int>& d, vector<int>& p, vector<int>& w) {\n        vector<pair<int,int>>v;\n        for(i
# Code\n```\nclass Solution {\npublic:\n    int maxProfitAssignment(vector<int>& d, vector<int>& p, vector<int>& w) {\n        vector<pair<int,int>>v;\n        for(int i=0;i<d.size();i++){\n            v.push_back({d[i],p[i]});\n        }\n        sort(v.begin(),v.end());\n        int n=d.size();\n        vector<int>dp(n+1);\n        dp[0]=v[0].second;\n        for(int i=1;i<n;i++){\n            dp[i]=max(dp[i-1],v[i].second);\n        }\n        sort(d.begin(),d.end());\n        int s=0;\n        for(int i=0;i<w.size();i++){\n           int in=upper_bound(d.begin(),d.end(),w[i])-d.begin();\n           if(in!=0){\n               in--;\n               s+=dp[in];\n           }\n        }\n        return s;\n    }\n};\n```\n![upvote (3).jpg](https://assets.leetcode.com/users/images/44d7abb5-b520-4d81-b589-567c12aa2091_1677164915.7858884.jpeg)\n\n
['Array', 'Binary Search', 'C++']