C. [AMPPZ 2019] Assimilation

    远端评测题 1000ms 512MiB

[AMPPZ 2019] Assimilation

该比赛已结束,您无法在比赛模式下递交该题目。您可以点击“在题库中打开”以普通模式查看和递交本题。

Description

An enlightened race of aliens plans to assimilate a star system, to help its inhabitants achieve perfection. They may resist, but — as you are all well aware — resistance is futile.

There are n n planets in the system, inhabited by a1,a2,,an a_1, a_2, \ldots, a_n people, respectively. Aliens start with k k assimilation ships and are allowed to make any of the following moves:

  • An invasion requires landing on a planet with some part of the fleet. The number of landing ships s s must be greater or equal to the population m m of the planet. After the invasion, these ships disappear, the planet is conquered and now has m+s m + s inhabitants.

  • A mobilization creates, from a conquered planet, a number of new ships equal to the population of the planet. Every planet can be mobilized at most once.

For Aliens, invasions are easy and natural, but mobilizations turn out to be a bit tricky. Help them conquer all the planets in the system with minimal possible number of mobilizations.

Input Format

The first line of input contains the number of test cases z z (1z30)(1 \le z \le 30). The test cases follow, each one in the following format:

  • The first line of every test case contains two integers n n and k k (1n200000;1k109)(1 \le n \le 200\,000; 1 \le k \le 10^9) — the number of planets, and the size of Aliens’ initial fleet.
  • The second line contains n n integers a1,,an a_1, \ldots, a_n (1ai109)(1 \le a_i \le 10^9) — the populations of the respective planets.

The sum of n n values over all test cases does not exceed 500,000500,000.

Output Format

For every test case, output a single integer: the minimal number of mobilizations required to conquer all the planets. If such conquest is impossible, output 1-1 instead.

4
3 15
6 5 26
3 15
6 5 27
2 1000000000
500123123 497000000
7 2
6 2 4 1 9 3 12
2
-1
0
4

ICPC欢乐赛

未参加
状态
已结束
规则
XCPC
题目
8
开始于
2026-2-7 8:30
结束于
2026-2-7 12:30
持续时间
4 小时
主持人
参赛人数
22