Assign the maximum number of tasks to workers using optional pills that boost worker strength.
You are given a list of task requirements and a list of workers. Each task requires a certain strength to complete, and each worker has a base strength. You may give a limited number of pills, each of which temporarily increases one worker's strength by a fixed amount. A worker can complete at most one task, and each task can be assigned to at most one worker.
Your goal is to determine the maximum number of tasks that can be completed if you assign tasks and pills optimally.
This is a classic feasibility problem: decide whether a given number of tasks can be assigned, then use that check to find the maximum possible count.
tasks where tasks[i] is the strength needed for the i-th task.workers where workers[j] is the base strength of the j-th worker.pills and strength.A pill can be used on at most one worker and increases that worker's strength by strength for the assignment.
Return the maximum number of tasks that can be completed.
pills workers may receive a pill.k such that some k tasks can be assigned successfully.Example 1
Input
tasks = [3,2,1] workers = [0,3,3] pills = 1 strength = 1
Output
3
Explanation
Assign task 1 to a worker with strength 3, task 2 to the other strength-3 worker, and use the pill on the worker with strength 0 to finish task 3.
Example 2
Input
tasks = [5,4] workers = [0,0,0] pills = 2 strength = 3
Output
0
Explanation
Even with pills, each worker reaches strength 3, which is still not enough for either task.
Premium problem context
Premium adds guided hints, editorial links, similar variants, discussion resources, and concept maps so you can understand why a problem matters, not just solve it once.