Python, sorting, bisect
Intuition\nThe main idea is to get maximum profit for current worker ability.\nFirst of all we need to mix together difficulty and profit, sort them and initial
# Intuition\nThe main idea is to get maximum profit for current worker ability.\nFirst of all we need to mix together difficulty and profit, sort them and initialize dp variable with maximum value with at least current difficulty. \n\n# Complexity\n- Time complexity:\nO(N*LogN) for sorting and bisect\n\n- Space complexity:\nO(1)\n\n# Code\n```\nimport bisect\n\nclass Solution:\n    def maxProfitAssignment(self, difficulty: List[int], profit: List[int], worker: List[int]) -> int:\n        difficultyProfit = list(zip(difficulty, profit))\n        difficultyProfit.sort()\n\n        difficulty, profit = zip(*difficultyProfit)\n\n        n = len(profit)\n        dp = [0] * n\n        for i in range(n):\n            dp[i] = max(profit[i], dp[i - 1])\n\n        result = 0\n        for w in worker:\n            index = bisect.bisect_right(difficulty, w) - 1\n            if index < 0:\n                continue\n            \n            result += dp[index]\n        \n        return result\n\n\n```
['Python3']