Calculate Maximum Quality Score
Imagine you're a seller on Amazon, specializing in eco-friendly products. Each of your items is rated by customers based on its quality and environmental impact.
The overall qualityScore of your products is determined by the maximum possible sum of consecutive ratings.
To improve the qualityScore of your products and attract more customers, you are given with an integer impactFactor and the following two strategies:
impactFactor.impactFactor
Your task is to determine the maximum possible qualityScore for your eco-friendly products after applying exactly one of these strategies.
Note: When applying the second strategy i.e., Adjust Ratings; For dividing positive ratings, floor the division result, and for dividing negative ratings, use the ceiling value of the division result,
Example: Given ratings = [4, -5, 5, -7, 1], and impactFactor = 2.
If we choose to apply the second strategy with segment [2, 5] (Assuming 1-based indexing) then, modified ratings: [4, ceil(-5/2), floor(5/2 [I think it should be 5/2 instead of S / 2], ceil(-7/2), floor(1/2)] = [4, -2, 2, -3, 0].
Note that the ceil(-7/2) = -3 and floor(5/2) = 2,
Given an array of ratings of size n and an integer impactFactor, determine the maximum possible qualityScore i.e., maximum possible sum of consecutive ratings by optimally selecting exactly one of the strategies to modify the ratings.
Complete the function calculateMaxQualityScore in the editor below
calculateMaxQualityScore has the following parameters:
int impactFactor: the value used in the strategies to amplify or adjust ratings.int ratings[n]: an array representing the ratings of eco-friendly products
Returns
long: the maximum possible qualityScore of your eco-friendly products after applying exactly one of the strategies.
Possible solution hint -> Basically, if the array is not entirely negative, find the max sum subarray and multiply it by the factor. If the array is entirely negative, find the single largest negative number and divide it by the factor.
🐳 Hello spike! Thanks for carrying~ 💪
1Example 1

qualityScore of 12, which is the maximum qualityScore.
Hence, the answer is 12.2Example 2
Constraints
Limits and guarantees your solution can rely on.
1 <= n <= 2 * 10^51 <= impactFactor <= 10^4-10^5 <= ratings[i] <= 10^5