You are given a queue of tasks, where tasks[i] is the time task i needs, and a deadline. Schedule the tasks on identical processors and return the minimum number of processors required so that every task is processed by deadline.
Processing rules:
0 and runs one task at a time, without interruption.deadline.If no number of processors meets the deadline, return -1.
Input: tasks = [3,2,4,1,2], deadline = 6
Output: 2
One processor needs 12 time units. With two, the tasks finish at 3, 2, 6, 4 and 6: the processor running 3 then takes 1 and 2, the other runs 2 then 4.
Input: tasks = [3,3,2,2,2], deadline = 6
Output: 3
The work totals 12 = 2 × 6, but two processors are not enough here: the first two tasks finish at 3, the next two at 5, and the last task starts at 5 and ends at 7. Three processors finish everything by 5.
Input: tasks = [4,7,2], deadline = 6
Output: -1
The task of length 7 alone runs past 6, however many processors there are.
1 <= tasks.length <= 10^51 <= tasks[i] <= 10^41 <= deadline <= 10^9