Tap here to switch tabs
Problem
Submissions

Problem: Maximum Number of Tasks You Can Assign

med
30 min
Try to solve the Maximum Number of Tasks You Can Assign problem.

Statement

You are given two 00 indexed integer arrays tasks and workers, where tasks[i] represents the strength required to complete the iextthi^{ ext{th}} task, and workers[j] represents the strength of the jextthj^{ ext{th}} worker.

You are also given two integers, pills and strength. You have pills magical pills available, each capable of increasing a worker’s strength by strength. Each worker may receive at most 11 magical pill.

Each worker can be assigned to at most 11 task, and a worker can complete a task only if their strength (with or without a pill) is greater than or equal to the task’s required strength.

Return the maximum number of tasks that can be completed.

Constraints:

  • n == tasks.length

  • m == workers.length

  • 1≤1 \leq n, m ≤5imes104\leq 5 imes 10^4

  • 0≤0 \leq pills ≤\leq m

  • 0≤0 \leq tasks[i], workers[j], strength ≤109\leq 10^9

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Maximum Number of Tasks You Can Assign

med
30 min
Try to solve the Maximum Number of Tasks You Can Assign problem.

Statement

You are given two 00 indexed integer arrays tasks and workers, where tasks[i] represents the strength required to complete the iextthi^{ ext{th}} task, and workers[j] represents the strength of the jextthj^{ ext{th}} worker.

You are also given two integers, pills and strength. You have pills magical pills available, each capable of increasing a worker’s strength by strength. Each worker may receive at most 11 magical pill.

Each worker can be assigned to at most 11 task, and a worker can complete a task only if their strength (with or without a pill) is greater than or equal to the task’s required strength.

Return the maximum number of tasks that can be completed.

Constraints:

  • n == tasks.length

  • m == workers.length

  • 1≤1 \leq n, m ≤5imes104\leq 5 imes 10^4

  • 0≤0 \leq pills ≤\leq m

  • 0≤0 \leq tasks[i], workers[j], strength ≤109\leq 10^9