CF1759E.The Humanoid

普及/提高-

通过率:0%

时间限制:2.00s

内存限制:256MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

There are nn astronauts working on some space station. An astronaut with the number ii (1≤i≤n1 \le i \le n) has power aia_i.

An evil humanoid has made his way to this space station. The power of this humanoid is equal to hh. Also, the humanoid took with him two green serums and one blue serum.

In one second , a humanoid can do any of three actions:

  1. to absorb an astronaut with power strictly less humanoid power;
  2. to use green serum, if there is still one left;
  3. to use blue serum, if there is still one left.

When an astronaut with power aia_i is absorbed, this astronaut disappears, and power of the humanoid increases by ⌊ai2⌋\lfloor \frac{a_i}{2} \rfloor, that is, an integer part of ai2\frac{a_i}{2}. For example, if a humanoid absorbs an astronaut with power 44, its power increases by 22, and if a humanoid absorbs an astronaut with power 77, its power increases by 33.

After using the green serum, this serum disappears, and the power of the humanoid doubles, so it increases by 22 times.

After using the blue serum, this serum disappears, and the power of the humanoid triples, so it increases by 33 times.

The humanoid is wondering what the maximum number of astronauts he will be able to absorb if he acts optimally.

有 nn 名宇航员在某空间站工作。编号为 ii(1≤i≤n1 \le i \le n)的宇航员拥有力量值 aia_i。

一名邪恶的人形生物已潜入该空间站。该人形生物当前的力量值为 hh,且随身携带两支绿色血清和一支蓝色血清。

每秒钟,该人形生物可执行以下三种操作之一:

  1. 吸收一名力量值严格小于自身当前力量值的宇航员;
  2. 使用一支绿色血清(前提是尚存至少一支);
  3. 使用一支蓝色血清(前提是尚存至少一支)。

当人形生物吸收一名力量值为 aia_i 的宇航员时,该宇航员消失,而人形生物的力量值增加 ⌊ai2⌋\lfloor \frac{a_i}{2} \rfloor,即 ai2\frac{a_i}{2} 的整数部分。例如:若吸收力量值为 44 的宇航员,则力量值增加 22;若吸收力量值为 77 的宇航员,则力量值增加 33。

使用绿色血清后,该血清被消耗,人形生物的力量值变为原来的 2 倍。

使用蓝色血清后,该血清被消耗,人形生物的力量值变为原来的 3 倍。

该人形生物想知道:若采取最优策略,最多能吸收多少名宇航员?

输入格式

The first line of each test contains an integer tt (1≤t≤1041 \le t \le 10^4) — number of test cases.

The first line of each test case contains integers nn (1≤n≤2⋅1051 \le n \le 2 \cdot 10^5) — number of astronauts and hh (1≤h≤1061 \le h \le 10^6) — the initial power of the humanoid.

The second line of each test case contains nn integers aia_i (1≤ai≤1081 \le a_i \le 10^8) — powers of astronauts.

It is guaranteed that the sum of nn for all test cases does not exceed 2⋅1052 \cdot 10^5.

每组测试数据的第一行包含一个整数 tt(1≤t≤1041 \le t \le 10^4)—— 测试用例的数量。

每个测试用例的第一行包含两个整数 nn(1≤n≤2⋅1051 \le n \le 2 \cdot 10^5)—— 宇航员的数量,以及 hh(1≤h≤1061 \le h \le 10^6)—— 类人生物的初始能量值。

每个测试用例的第二行包含 nn 个整数 aia_i(1≤ai≤1081 \le a_i \le 10^8)—— 各宇航员的能量值。

保证所有测试用例的 nn 值之和不超过 2⋅1052 \cdot 10^5。

输出格式

For each test case, in a separate line, print the maximum number of astronauts that a humanoid can absorb.

对于每个测试用例,在单独一行中输出一个人形生物最多能吸收的宇航员数量。

输入输出样例

  • 输入#1

    8
    4 1
    2 1 8 9
    3 3
    6 2 60
    4 5
    5 1 100 5
    3 2
    38 6 3
    1 1
    12
    4 6
    12 12 36 100
    4 1
    2 1 1 15
    3 5
    15 1 13

    输出#1

    4
    3
    3
    3
    0
    4
    4
    3

说明/提示

In the first case, you can proceed as follows:

  1. use green serum. h=1⋅2=2h = 1 \cdot 2 = 2
  2. absorb the cosmonaut 22. h=2+⌊12⌋=2h = 2 + \lfloor \frac{1}{2} \rfloor = 2
  3. use green serum. h=2⋅2=4h = 2 \cdot 2 = 4
  4. absorb the spaceman 11. h=4+⌊22⌋=5h = 4 + \lfloor \frac{2}{2} \rfloor = 5
  5. use blue serum. h=5⋅3=15h = 5 \cdot 3 = 15
  6. absorb the spaceman 33. h=15+⌊82⌋=19h = 15 + \lfloor \frac{8}{2} \rfloor = 19
  7. absorb the cosmonaut 44. h=19+⌊92⌋=23h = 19 + \lfloor \frac{9}{2} \rfloor = 23

在第一种情况下,你可以按如下步骤进行:

  1. 使用绿色血清。h=1⋅2=2h = 1 \cdot 2 = 2
  2. 吸收宇航员 22。h=2+⌊12⌋=2h = 2 + \lfloor \frac{1}{2} \rfloor = 2
  3. 使用绿色血清。h=2⋅2=4h = 2 \cdot 2 = 4
  4. 吸收宇航员 11。h=4+⌊22⌋=5h = 4 + \lfloor \frac{2}{2} \rfloor = 5
  5. 使用蓝色血清。h=5⋅3=15h = 5 \cdot 3 = 15
  6. 吸收宇航员 33。h=15+⌊82⌋=19h = 15 + \lfloor \frac{8}{2} \rfloor = 19
  7. 吸收宇航员 44。h=19+⌊92⌋=23h = 19 + \lfloor \frac{9}{2} \rfloor = 23

输入解题思路,AI测评打分。不知道怎么写?

首页