There are n
jobs that can be executed in parallel on a processor, where the execution time
of the j
th job is executionTime[j]. To speed up execution, the following strategy
is used.
In one operation, a job is chosen, the major job, and is executed for x
seconds. All other jobs
are executed for y
seconds where y < x
.
A job is complete when it has been executed for at least executionTime[i] seconds, then it exits the pool. Find the minimum number of operations in which the processor can completely execute all the jobs if run optimally.
Function Description
Complete the function getMinimumOperations
in the editor below.
getMinimumOperations
has the following parameters:
int executionTime[n]
: the execution times of each jobint x
: the time for which the major job is executedint y
: the time for which all other jobs are executed
Returns
int
: the minimum number of operations in which the processor can complete the jobs
Example 1:
Input: executionTime = [3, 4, 1, 7, 6], x = 4, y = 2
Output: 3
Explanation:The following strategy is optimal using 1-based indexing. 1. Choose job 4 as the major job and reduce the execution times of job 4 by x and of other jobs by y. So, executionTime = [1, 2, -1, 1, 4], Job 3 is complete, so it is removed. 2. Choose job 5 as the major job and reduce the execution times of job 5 by x and of other jobs by y. So, executionTime = [-1, 0, -3, -1, 2], Jobs 1, 2, and 4 are now complete. 3. Choose job 5, executionTime = [-3, -2, -5, -3, -4], Job 5 is complete. It takes 3 operations to execute all the jobs so the answer is 3.
- 1 β€ n β€ 10^5
- 1 β€ executionTime[i] β€ 10^9^
- 1 β€ y < x β€ 10^9

input:
output: