Minimum Bonus Projects
Problem statement
You are given an array errorScores of nonnegative employee error scores and two reductions selectedReduction and otherReduction, where selectedReduction > otherReduction.
In one bonus-project operation, choose one employee. That employee's score decreases by selectedReduction, while every other employee's score decreases by otherReduction. A score that would become negative is treated as 0.
Return the minimum number of operations required to reduce every score to 0.
Function
minimumBonusProjects(errorScores: long[], selectedReduction: long, otherReduction: long) → longExamples
Example 1
errorScores = [6,4,1]selectedReduction = 4otherReduction = 1return = 3Three operations suffice. With only two operations, the total number of extra selected reductions required is greater than two.
Example 2
errorScores = [5]selectedReduction = 2otherReduction = 0return = 3The sole employee must be selected three times.
Example 3
errorScores = [3,3]selectedReduction = 3otherReduction = 1return = 2Select each employee once. Each receives one reduction of 3 and one reduction of 1, which is enough to reach zero.
Example 4
errorScores = [0,0]selectedReduction = 5otherReduction = 1return = 0Every score is already zero.
Constraints
1 <= errorScores.length <= 10^5.0 <= errorScores[i] <= 10^9.0 <= otherReduction < selectedReduction <= 10^9.