Maximize Quality Score of Products
Problem Statement
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 sum of consecutive ratings.
To improve the qualityScore, you are given two strategies:
- Amplify Ratings: Select a contiguous segment of ratings and amplify each rating in that range by
impactFactor
. - Adjust Ratings: Select a contiguous segment of ratings and adjust them by dividing each rating in that range by
impactFactor
(use the ceiling value for negative ratings).
Your task is to determine the maximum possible qualityScore after applying exactly one of these strategies.
Example
- Input:
ratings = [5, -3, -3, 2, 4]
,impactFactor = 3
- Output:
12
Explanation:
- Try both strategies on different ranges:
- Amplify
[4, 5]
:[5, -3, -3, 4*2, 2*3] = [5, -3, -3, 8, 12]
,qualityScore = 12
. - Adjust
[2, 3]
:[5, ceil(-3/3), ceil(-3/3), 2, 4] = [5, -1, -1, 2, 4]
,qualityScore = 9
.
Thus, the answer is12
.
- Amplify
Detailed Table for Example:
Strategy | Segment (1-based indexing) | Modified Ratings | qualityScore |
---|---|---|---|
Amplify | [1, 1] | [5*2, -3, -3, 2, 4] | 10 |
Adjust | [2, 3] | [5, -1, -1, 2, 4] | 9 |
Amplify | [4, 5] | [5, -3, -3, 8, 12] | 12 |
If we perform the first strategy on the subsegment [4, 5]
(1-based indexing), we get the ratings [5, -3, -3, 8, 12]
with a qualityScore
of 12
, which is the maximum.
Thus, the answer is 12
.
CSOAhelp长期稳定承接各大科技公司如TikTok、Google、Amazon等的OA笔试代写服务,确保满分通过。如有需求,请随时联系我们。
CSOAhelp consistently provide professional online assessment services for major tech companies like TikTok, Google, and Amazon, guaranteeing perfect scores. Feel free to contact us if you're interested.