#K53437. Maximize Sequence Value
Maximize Sequence Value
Maximize Sequence Value
You are given a sequence of n integers and an integer k. In each test case, you are allowed to perform exactly k operations. In each operation, you must add 1 to the current maximum element of the sequence. After performing all operations, output the maximum value in the sequence.
Mathematically, if the initial maximum is \( M \), then the answer is \( M + k \).
Input Format: The first line contains an integer T representing the number of test cases. Each test case consists of two lines. The first line has two integers \( n \) and \( k \) where \( n \) is the number of elements in the sequence. The following line contains \( n \) space-separated integers representing the sequence.
Output Format: For each test case, output a single integer — the maximum value in the sequence after performing the operations.
inputFormat
The input is read from standard input (stdin) and formatted as follows:
T n1 k1 a1 a2 ... an1 n2 k2 a1 a2 ... an2 ...
Where T is the number of test cases, each test case starts with two integers \( n \) and \( k \), followed by a line with \( n \) integers.
outputFormat
For each test case, output the result on a new line. The result for a test case is the maximum integer in the sequence after adding 1 to the original maximum element k times.
## sample3
5 3
1 2 4 5 3
4 7
4 4 4 4
3 2
10 1 10
8
11
12
</p>