Problem: You are given an array , consisting of integers. You are also given an integer value .
Let be the maximum sum of a contiguous subarray of after applying the following operation: add to the elements on exactly distinct positions. An empty subarray should also be considered, it has sum .
Note that the subarray doesn't have to include all of the increased elements.
Calculate the maximum value of for all from to independently.
Input Format: The first line contains a single integer () — the number of testcases.
The first line of the testcase contains two integers and (; ) — the number of elements in the array and the value to add.
The second line contains integers ().
The sum of over all testcases doesn't exceed .
Output Format: For each testcase, print integers — the maximum value of for all from to independently.
Note: In the first testcase, it doesn't matter which elements you add to. The subarray with the maximum sum will always be the entire array. If you increase elements by , will be added to the sum.
In the second testcase:
- For , the empty subarray is the best option.
- For , it's optimal to increase the element at position . The best sum becomes for a subarray .
- For , it's optimal to increase the element at position and any other element. The best sum is still for a subarray .
- For , you have to increase all elements. The best sum becomes for a subarray .