Task Queue
Task queues, which allow for asynchronous performance, are an important part of modern processing architectures. Information about a system consisting of several batch processing queues is given.
Each queue has three parameters:
- the maximum number of tasks it can process in a single batch.
- the time it takes to process a single batch of tasks in that queue
- the number of tasks the queue must process
Given this information. calculate the minimum time needed to process a set of tasks by the system.
Example
n = 2
batchSize = [4,3]
processingTime = [6,5]
numTasks = [8,8]
Queue 0 can process a max of 4 tasks in 6 minutes, and queue 1 can process a max of 3 tasks in 5 minutes. Each queue has 8 tasks to process. The time required to perform the assigned tasks in the minimu possible time is calculated as follows:
For queue 0:
- At time = 0, a new batch of 4 tasks is initiated
- At time = 6, the first batch of tasks is processed and a new batch of 4 tasks is initiated.
- At time = 12, the second batch of tasks is processed. There are no more tasks left to process
For queue 1:
- At time=0, a new batch of 3 tasks is initiated.
- At time = 5, the first batch of tasks is processed and a new batch of 3 tasks is initiated
- At time = 10, the second batch of tasks is processed and a new batch of 2 tasks is initiated.
The min time to process all tasks is 15
Constraints:
- 1 <= n <= 10^5
- 1 <= batchSize[i] <= 10^9
- 1 <= processingTime[i] <= 10^5
- 1 <= numTasks[i] <= 10^9