CF2042A.Greedy Monocarp

传统题 时间 2000 ms 内存 256 MiB 3 尝试 1 已通过 1 标签

Greedy Monocarp

There are nn chests; the ii-th chest initially contains aia_i coins. For each chest, you can choose any non-negative (00 or greater) number of coins to add to that chest, with one constraint: the total number of coins in all chests must become at least kk.

After you've finished adding coins to the chests, greedy Monocarp comes, who wants the coins. He will take the chests one by one, and since he is greedy, he will always choose the chest with the maximum number of coins. Monocarp will stop as soon as the total number of coins in chests he takes is at least kk.

You want Monocarp to take as few coins as possible, so you have to add coins to the chests in such a way that, when Monocarp stops taking chests, he will have exactly kk coins. Calculate the minimum number of coins you have to add.

Input

The first line contains one integer tt (1t10001 \le t \le 1000) — the number of test cases.

Each test case consists of two lines:

  • the first line contains two integers nn and kk (1n501 \le n \le 50; 1k1071 \le k \le 10^7);
  • the second line contains nn integers a1,a2,,ana_1, a_2, \dots, a_n (1aik1 \le a_i \le k).

Output

For each test case, print one integer — the minimum number of coins you have to add so that, when Monocarp stops taking the chests, he has exactly kk coins. It can be shown that under the constraints of the problem, it is always possible.

Note

In the first test case of the example, you don't have to add any coins. When Monocarp arrives, he will take the chest with 44 coins, so he will have exactly 44 coins.

In the second test case of the example, you can add 11 coin to the 44-th chest, so, when Monocarp arrives, he will take a chest with 44 coins, then another chest with 44 coins, and a chest with 22 coins.

In the third test case of the example, you can add 33 coins to the 11-st chest and 55 coins to the 22-nd chest.

In the fourth test case of the example, you can add 11 coin to the 11-st chest and 11 coin to the 33-rd chest.

Samples

4
5 4
4 1 2 3 2
5 10
4 1 2 3 2
2 10
1 1
3 8
3 3 3
0
1
8
2

在线编程 IDE

建议全屏模式获得最佳体验