CF2128A.Recycling Center

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

Recycling Center

In the recycling center, there are nn trash bags, the ii-th bag has a weight of aia_i. At each second, two actions will happen successively:

  • First, you must choose a trash bag and destroy it. It will cost 11 coin if the weight of the trash bag is strictly greater than cc, and it will cost 00 coins otherwise.
  • Then, the weight of each remaining trash bag will get multiplied by two.

What is the minimum number of coins you have to spend to get rid of all trash bags?

Input

Each test contains multiple test cases. The first line contains the number of test cases tt (1t10001 \le t \le 1000). The description of the test cases follows.

The first line of each test case contains two integers nn and cc (1n301 \leq n \leq 30, 1c109)1 \leq c \leq 10^9).

The second line of each test case contains nn integers a1,a2,,ana_1, a_2, \ldots, a_n (1ai1091 \leq a_i \leq 10^9) — the weight of each trash bag.

Output

For each test case, you must output a single integer — the minimum number of coins you have to spend to destroy all trash bags.

Note

In the following explanation:

  • Numbers in blue represent trash bags that have been destroyed for free,
  • Numbers in red represent trash bags that have been destroyed for 11 coin,
  • Numbers in black represent trash bags that have not been destroyed yet.

In the first test case, one solution is:

  • [10,4,15,1,8][10, 4, 15, 1, 8]
  • [10,8,30,2,16][\color{blue}{10}, 8, 30, 2, 16], 1010 is destroyed for free because 101010 \leq 10.
  • [10,8,60,4,32][\color{blue}{10}, \color{blue}{8}, 60, 4, 32], 88 is destroyed for free because 8108 \leq 10.
  • $[\color{blue}{10}, \color{blue}{8}, 120, 8, \color{red}{32}]$, 3232 is destroyed for 11 coin because 32>1032 \gt 10.
  • $[\color{blue}{10}, \color{blue}{8}, 240, \color{blue}{8}, \color{red}{32}]$, 88 is destroyed for free because 8108 \leq 10.
  • $[\color{blue}{10}, \color{blue}{8}, \color{red}{240}, \color{blue}{8}, \color{red}{32}]$, 240240 is destroyed for 11 coin because 240>10240 \gt 10.

In total, you paid 22 coins, and we can prove it is optimal.

In the second test case, one solution is:

  • $[1\,000\,000\,000, 1\,000\,000\,000, 1\,000\,000\,000]$
  • $[\color{red}{1\,000\,000\,000}, 2\,000\,000\,000, 2\,000\,000\,000]$, 10000000001\,000\,000\,000 is destroyed for 11 coin because 1000000000>421\,000\,000\,000 \gt 42.
  • $[\color{red}{1\,000\,000\,000}, \color{red}{2\,000\,000\,000}, 4\,000\,000\,000]$, 20000000002\,000\,000\,000 is destroyed for 11 coin because 2000000000>422\,000\,000\,000 \gt 42.
  • $[\color{red}{1\,000\,000\,000}, \color{red}{2\,000\,000\,000}, \color{red}{4\,000\,000\,000}]$, 40000000004\,000\,000\,000 is destroyed for 11 coin because 4000000000>424\,000\,000\,000 \gt 42.

Samples

4
5 10
10 4 15 1 8
3 42
1000000000 1000000000 1000000000
10 30
29 25 2 12 15 42 14 6 16 9
10 1000000
1 1 1 1 1 1 1 1 1 864026633
2
3
6
1

在线编程 IDE

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