Company: Amazon,HackerRank_11thjuly
Difficulty: hard
Maximum Performance Score You are given an integer array metrics and an integer scaleFactor . The performance score of an array is the maximum sum of a non-empty contiguous subarray. You must apply exactly one operation to exactly one non-empty contiguous segment of metrics : 1. Multiply every value in the segment by scaleFactor . 2. Divide every value in the segment by scaleFactor , truncating the result toward zero. Return the maximum performance score obtainable after the operation. Input Format The first line contains scaleFactor . The second line contains n , the number of metrics. Each of the next n lines contains one element of metrics . Output Format Print one integer: the maximum possible performance score. Examples Example 1 Input: 1 4 -2 3 -3 -1 Output: 3 scaleFactor = 1 , so either operation leaves all values unchanged. Example 2 Input: 3 1 -4 Output: -1 Dividing the only value gives -1 ; integer division truncates toward zero. Example 3 Input: 2 5 5 -3 -3 2 4 Output: 12 Mu