| Codeforces Round 1047 (Div. 3) |
|---|
| Finished |
You are given an array $$$a$$$ of size $$$n$$$ and an integer $$$k$$$. You do the following procedure $$$k$$$ times:
Please find the sum of elements in the array after all $$$k$$$ operations.
$$$^{\text{∗}}$$$The minimum excluded (MEX) of a collection of integers $$$d_1, d_2, \ldots, d_k$$$ is defined as the smallest non-negative integer $$$x$$$ which does not occur in the collection $$$d$$$.
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 10^4$$$). The description of the test cases follows.
The first line contains two integers $$$n$$$ and $$$k$$$ ($$$2 \leq n \leq 2\cdot 10^5, 1 \leq k \leq 10^9$$$) – the number of elements in $$$a$$$ and the number of operations done.
The second line contains $$$n$$$ integers $$$a_1,a_2,\ldots,a_n$$$ ($$$0 \leq a_i \leq n$$$).
It is guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$2\cdot 10^5$$$.
For each test case, output the sum of elements after all $$$k$$$ operations on a new line.
53 30 2 12 40 24 10 0 1 18 76 6 2 4 3 0 1 82 20 0
3 1 8 25 0
In the first test case, we performed the operation on the array $$$[0,2,1]$$$ three times. Let's compute the result after the first time:
So, after the first operation, $$$[0,2,1]$$$ becomes $$$[0,2,1]$$$ again. It can be shown that the array will not change no matter how many times we perform the operation, so the final array after three operations is still $$$[0,2,1]$$$. The sum is $$$0+2+1=3$$$.
In the third test case, the array becomes $$$[2,2,2,2]$$$.
| Name |
|---|


