#K88842. Maximum Element After Operations
Maximum Element After Operations
Maximum Element After Operations
You are given an integer T representing the number of test cases. For each test case, you are provided with two integers N and K followed by N space-separated integers representing an array.
You are allowed to perform exactly K operations. In each operation, you may increase any one element of the array by 1
. Your goal is to maximize the value of the largest element in the array after performing all K operations.
Observation: The optimal strategy is to perform all operations on the current maximum element, thereby increasing it by K. Hence, the answer for each test case is max(array) + K
.
Example:
Input: 1 3 5 100 200 300</p>Output: 305
inputFormat
The first line of input contains a single integer T, the number of test cases. For each test case, the first line contains two integers N and K, where N is the number of elements in the array and K is the number of operations allowed. The second line contains N space-separated integers representing the array.
outputFormat
For each test case, print a single line containing the maximum possible value of any element in the array after performing exactly K operations.## sample
2
5 3
1 2 3 4 5
4 2
10 20 30 40
8
42
</p>