| Codeforces Round 1133 (Div. 1) |
|---|
| Finished |
You are given an array $$$a$$$ of length $$$n$$$ and a bound $$$\ell$$$. A pair of indices $$$1\le i \lt j \le n$$$ is called dangerous if $$$a_i \cdot a_j \ge \ell$$$.
In one operation, you can choose an index $$$i$$$ and decrease $$$a_i$$$ by $$$1$$$ (even if this makes $$$a_i$$$ zero or negative). Determine the minimum number of operations you have to apply to $$$a$$$ to make no pair of indices dangerous.
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 10^3$$$). The description of the test cases follows.
The first line of each test case contains the integers $$$n$$$ and $$$\ell$$$ ($$$2\le n\le 5\cdot 10^5$$$, $$$1\le \ell\le 10^9$$$) — the number of integers in $$$a$$$ and the bound, respectively.
The second line contains $$$n$$$ integers $$$a_1, a_2, \ldots, a_n$$$ ($$$1 \le a_i \le 10^9$$$) — the elements of $$$a$$$.
It is guaranteed that the sum of $$$n$$$ over all test cases is at most $$$5\cdot 10^5$$$.
For each testcase, output a single integer: the minimum number of operations you have to perform on the array to make every pair of indices not dangerous.
55 1110 2 6 3 14 51 2 3 32 133 44 91 1 1 96 10000000001000000000 1000000000 1 1000000000 1000000000 1000000000
82013999999997
In the first example, we can decrease each of the middle $$$3$$$ numbers down to $$$1$$$, which takes $$$1 + 5 + 2 = 8$$$ operations.
In the second example, we can decrease each of the last $$$2$$$ numbers down to $$$2$$$, which takes $$$2$$$ operations.
| Name |
|---|


