Get Minimum Operations
Learn this problemProblem statement
There are n jobs that can be executed in parallel on a processor, where the execution time of the ith job is executionTime[i]. 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
getMinimumOperations(executionTime: int[], x: int, y: int) → int
Complete the function getMinimumOperations in the editor.
getMinimumOperations has the following parameters:
int executionTime[]: 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
Examples
Example 1
executionTime = [3, 4, 1, 7, 6]x = 4y = 2return = 3The following strategy is optimal using 1-based indexing:
- Choose job 4 as the major job and reduce the execution times of job 4 by
x = 4and of other jobs byy = 2. NowexecutionTime = [1, 2, -1, 3, 4]. Job 3 is complete, so it is removed. - Choose job 4,
executionTime = [-1, 0, -, 1, 2]. So, jobs 1, 2, and 4 are now complete. - Choose job 5,
executionTime = [-, -, -, -, -2]. Job 5 is complete.
Constraints
1 ≤ n ≤ 10⁵1 ≤ executionTime[i] ≤ 10⁹1 ≤ y < x ≤ 10⁹
More Citadel problems
- Limit Order Book Matching EnginePHONE SCREEN · Seen Jul 2026
- Minimum Changes for a Periodic PalindromeOA · Seen Jul 2026
- Minimum Image Processing CostOA · Seen Jul 2026
- Minimum Path Sum to Target in Binary TreePHONE SCREEN · Seen Apr 2026
- Minimum Time to Process RequestsOA · Seen Mar 2026
- Process SchedulingOA · Seen Mar 2026
- Social Media SuggestionsOA · Seen May 2025
- Best Sum Downward Tree PathOA · Seen May 2025