🎁 Exclusive Offer! Join our
Telegram Channel
to get **special discounts** and updates! 🚀
Question 61 - 100% Working Solution | Buy Now
Description
3 Live
A company needs an efficient strategy to optimize resource allocation for servers based on performance metrics. The performance of each server is represented by performance[i], where 0 ≤ i < n. A server's rank is defined by the count of distinct performance metrics that are greater than or equal to its own performance metric.
To allocate resources, two positive integer constants, inc and dec, are used to determine increment and decrement values, respectively. The resource allocation for each server is calculated as follows:
resource allocation = inc × (n + 1 - server's rank) - dec × rank
The task is to calculate the resource allocation for each server based on their performance.
Example:
inc = 500
dec = 100
n = 6
performance = [3, 2, 4, 3, 5, 5]
Server index 0 has a rank of 3 since 3, 4, and 5 are greater than or equal to its performance of 3. The resource allocation is calculated as:
500 × (6 + 1 - 3) - 100 × 2 = 1800