Minimum Processing Time

You have a certain number of processors, each having 4 cores. The number of tasks to be executed is four times the number of processors. Each task must be assigned to a unique core, and each core can only be used once.

You are given an array processorTime representing the time each processor becomes available and an array tasks representing how long each task takes to complete.

Return the minimum time needed to complete all tasks.

Example 1
Inputprocessor_time = [8,10], tasks = [2,2,3,1,8,7,4,5]
Output16
Assigning the largest tasks to the processor available at time 8 and the smaller tasks to the processor available at time 10 makes the overall completion time 16.
Example 2
Inputprocessor_time = [10,20], tasks = [2,3,1,2,5,8,4,3]
Output23
With an optimal assignment, the first processor finishes by time 18 and the second finishes by time 23, so all tasks complete at time 23.

Constraints

  • 1 <= n == processorTime.length <= 25000
  • 1 <= tasks.length <= 10^5
  • 0 <= processorTime[i] <= 10^9
  • 1 <= tasks[i] <= 10^9
  • tasks.length == 4 * n

Asked at 3 companies

</>

Your Solution

(Ctrl/Cmd + Enter)

Switching Language

Loading template...

Loading...

Sign in to save your progress

AI code evaluation

Get a correctness verdict, missed edge cases, and complexity analysis of your solution.

Sign in to evaluate