Company: Amazon,HackerRank
Difficulty: hard
Imagine you're a cloud services manager on Amazon Web Services, specializing in high-performance computing solutions. Each of your services is evaluated by clients based on its reliability and throughput capacity. The overall performanceScore of your services is the maximum possible sum of consecutive metrics (the maximum sum over all non-empty contiguous subarrays). To improve the performanceScore you are given an integer scaleFactor and the following two strategies: Boost Metrics: select a contiguous segment of metrics and boost them by multiplying each metric in that range by scaleFactor . Normalize Metrics: select a contiguous segment of metrics and normalize them by dividing each metric in that range by scaleFactor . Your task is to determine the maximum possible performanceScore after applying exactly one of these strategies to exactly one non-empty contiguous segment . Notes When applying the second strategy: for dividing positive metrics use the floor of the division result, an