Class Solution
java.lang.Object
g0801_0900.s0826_most_profit_assigning_work.Solution
826 - Most Profit Assigning Work.<p>Medium</p>
<p>You have <code>n</code> jobs and <code>m</code> workers. You are given three arrays: <code>difficulty</code>, <code>profit</code>, and <code>worker</code> where:</p>
<ul>
<li><code>difficulty[i]</code> and <code>profit[i]</code> are the difficulty and the profit of the <code>i<sup>th</sup></code> job, and</li>
<li><code>worker[j]</code> is the ability of <code>j<sup>th</sup></code> worker (i.e., the <code>j<sup>th</sup></code> worker can only complete a job with difficulty at most <code>worker[j]</code>).</li>
</ul>
<p>Every worker can be assigned <strong>at most one job</strong> , but one job can be <strong>completed multiple times</strong>.</p>
<ul>
<li>For example, if three workers attempt the same job that pays <code>$1</code>, then the total profit will be <code>$3</code>. If a worker cannot complete any job, their profit is <code>$0</code>.</li>
</ul>
<p>Return the maximum profit we can achieve after assigning the workers to the jobs.</p>
<p><strong>Example 1:</strong></p>
<p><strong>Input:</strong> difficulty = [2,4,6,8,10], profit = [10,20,30,40,50], worker = [4,5,6,7]</p>
<p><strong>Output:</strong> 100</p>
<p><strong>Explanation:</strong> Workers are assigned jobs of difficulty [4,4,6,6] and they get a profit of [20,20,30,30] separately.</p>
<p><strong>Example 2:</strong></p>
<p><strong>Input:</strong> difficulty = [85,47,57], profit = [24,66,99], worker = [40,25,25]</p>
<p><strong>Output:</strong> 0</p>
<p><strong>Constraints:</strong></p>
<ul>
<li><code>n == difficulty.length</code></li>
<li><code>n == profit.length</code></li>
<li><code>m == worker.length</code></li>
<li><code>1 <= n, m <= 10<sup>4</sup></code></li>
<li><code>1 <= difficulty[i], profit[i], worker[i] <= 10<sup>5</sup></code></li>
</ul>
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionint
maxProfitAssignment
(int[] difficulty, int[] profit, int[] worker)
-
Constructor Details
-
Solution
public Solution()
-
-
Method Details
-
maxProfitAssignment
public int maxProfitAssignment(int[] difficulty, int[] profit, int[] worker)
-