CF1592A.Gamer Hemose

入门

通过率:0%

时间限制:1.00s

内存限制:256MB

AC君温馨提醒

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

题目描述

One day, Ahmed_Hossam went to Hemose and said "Let's solve a gym contest!". Hemose didn't want to do that, as he was playing Valorant, so he came up with a problem and told it to Ahmed to distract him. Sadly, Ahmed can't solve it... Could you help him?

There is an Agent in Valorant, and he has nn weapons. The ii-th weapon has a damage value aia_i, and the Agent will face an enemy whose health value is HH.

The Agent will perform one or more moves until the enemy dies.

In one move, he will choose a weapon and decrease the enemy's health by its damage value. The enemy will die when his health will become less than or equal to 00. However, not everything is so easy: the Agent can't choose the same weapon for 22 times in a row.

What is the minimum number of times that the Agent will need to use the weapons to kill the enemy?

一天,Ahmed_Hossam 找到 Hemose,说:“我们来打一场 Gym 比赛吧!”
但 Hemose 正在玩《Valorant》,并不想这么做,于是他想出了一道题告诉 Ahmed,想借此分散他的注意力。可惜 Ahmed 解不出来……你能帮他吗?

在《Valorant》中有一名特工,他拥有 nn 把武器。第 ii 把武器的伤害值为 aia_i,该特工将面对一名生命值为 HH 的敌人。

特工将执行一次或多次操作,直到敌人死亡。

每次操作中,他选择一把武器,并使敌人的生命值减少该武器的伤害值。当敌人的生命值变为小于等于 00 时,敌人即死亡。然而,并非一切如此简单:特工不能连续两次选择同一把武器。

请问,特工杀死敌人所需的最少武器使用次数是多少?

输入格式

Each test contains multiple test cases. The first line contains the number of test cases tt (1≤t≤105)(1 \leq t \leq 10^5). Description of the test cases follows.

The first line of each test case contains two integers nn and HH (2≤n≤103,1≤H≤109)(2 \leq n \leq 10^3, 1 \leq H \leq 10^9) — the number of available weapons and the initial health value of the enemy.

The second line of each test case contains nn integers a1,a2,…,ana_1, a_2, \ldots, a_n (1≤ai≤109)(1 \leq a_i \leq 10^9) — the damage values of the weapons.

It's guaranteed that the sum of nn over all test cases doesn't exceed 2⋅1052 \cdot 10^5.

每个测试包含多个测试用例。第一行包含测试用例的数量 tt (1≤t≤105)(1 \leq t \leq 10^5)。随后是各测试用例的描述。

每个测试用例的第一行包含两个整数 nn 和 HH (2≤n≤103,1≤H≤109)(2 \leq n \leq 10^3, 1 \leq H \leq 10^9) —— 分别表示可用武器的数量和敌人的初始生命值。

每个测试用例的第二行包含 nn 个整数 a1,a2,…,ana_1, a_2, \ldots, a_n (1≤ai≤109)(1 \leq a_i \leq 10^9) —— 表示各武器的伤害值。

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

输出格式

For each test case, print a single integer — the minimum number of times that the Agent will have to use the weapons to kill the enemy.

对于每个测试用例,输出一个整数——特工杀死敌人所需使用的武器的最少次数。

输入输出样例

  • 输入#1

    3
    2 4
    3 7
    2 6
    4 2
    3 11
    2 1 7

    输出#1

    1
    2
    3

说明/提示

In the first test case, the Agent can use the second weapon, making health value of the enemy equal to 4−7=−34-7=-3. −3≤0-3 \le 0, so the enemy is dead, and using weapon 11 time was enough.

In the second test case, the Agent can use the first weapon first, and then the second one. After this, the health of enemy will drop to 6−4−2=06-4-2 = 0, meaning he would be killed after using weapons 22 times.

In the third test case, the Agent can use the weapons in order (third, first, third), decreasing the health value of enemy to 11−7−2−7=−511 - 7 - 2 - 7 = -5 after using the weapons 33 times. Note that we can't kill the enemy by using the third weapon twice, as even though 11−7−7<011-7-7 \lt 0, it's not allowed to use the same weapon twice in a row.

在第一个测试用例中,特工可以使用第二把武器,使敌人的生命值变为 4−7=−34-7=-3。由于 −3≤0-3 \le 0,敌人死亡,因此仅需使用武器 11 次即可。

在第二个测试用例中,特工可以先使用第一把武器,再使用第二把武器。此后,敌人的生命值将降至 6−4−2=06-4-2 = 0,意味着只需使用武器 22 次即可将其击杀。

在第三个测试用例中,特工可以按顺序(第三把、第一把、第三把)使用武器,经过 33 次使用后,敌人的生命值将降至 11−7−2−7=−511 - 7 - 2 - 7 = -5。注意:我们不能通过连续两次使用第三把武器来击杀敌人,因为尽管 11−7−7<011-7-7 \lt 0,但规则不允许连续两次使用同一把武器。

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

首页