https://leetcode.com/problems/most-profit-assigning-work/description/
class Solution { public: int maxProfitAssignment(vector<int>& difficulty, vector<int>& profit, vector<int>& worker) { int res = 0; vector<pair<int,int>> jobs(difficulty.size()); for (int i = 0; i < difficulty.size(); i++) jobs[i] = { difficulty[i], profit[i] }; sort(jobs.begin(), jobs.end()); sort(worker.begin(), worker.end()); int i = 0, j = 0, p = 0; while (j < worker.size()) { while (i < jobs.size() && jobs[i].first <= worker[j]) { p = max(p, jobs[i].second); i++; } res += p; j++; } return res; } };