310630: CF1862F. Magic Will Save the World
Description
A portal of dark forces has opened at the border of worlds, and now the whole world is under a terrible threat. To close the portal and save the world, you need to defeat $n$ monsters that emerge from the portal one after another.
Only the sorceress Vika can handle this. She possesses two magical powers — water magic and fire magic. In one second, Vika can generate $w$ units of water mana and $f$ units of fire mana. She will need mana to cast spells. Initially Vika have $0$ units of water mana and $0$ units of fire mana.
Each of the $n$ monsters that emerge from the portal has its own strength, expressed as a positive integer. To defeat the $i$-th monster with strength $s_i$, Vika needs to cast a water spell or a fire spell of at least the same strength. In other words, Vika can spend at least $s_i$ units of water mana on a water spell, or at least $s_i$ units of fire mana on a fire spell.
Vika can create and cast spells instantly. Vika can cast an unlimited number of spells every second as long she has enough mana for that.
The sorceress wants to save the world as quickly as possible, so tell her how much time she will need.
InputEach test consists of several test cases. The first line of each test contains a single integer $t$ ($1 \le t \le 100$) — the number of test cases. This is followed by a description of the test cases.
The first line of each test case contains two integers $w$, $f$ ($1 \le w, f \le 10^9$) — the amount of water and fire mana that Vika can generate per second.
The second line of each test case contains a single integer $n$ ($1 \le n \le 100$) — the number of monsters.
The third line of each test case contains $n$ integers $s_1, s_2, s_3, \dots, s_n$ ($1 \le s_i \le 10^4$) — the strengths of the monsters.
It is guaranteed that the sum of $n$ over all test cases does not exceed $100$.
OutputFor each test case, output a single integer — the minimum time in seconds that Vika will need to defeat all the monsters.
ExampleInput4 2 3 3 2 6 7 37 58 1 93 190 90 2 23 97 13 4 4 10 10 2 45Output
3 2 1 5Note
In the first sample, after the first second, Vika can spend $2$ units of fire mana to kill the first monster. Then she has $2$ units of water mana and $1$ unit of fire mana. After the third second, she will have $6$ units of water mana and $7$ units of fire mana at her disposal. This will be enough to immediately kill the second and third monsters.
Output
一个黑暗力量的传送门在世界边界打开,整个世界都处于可怕威胁之中。为了关闭传送门并拯救世界,你需要击败从传送门出现的n只怪兽。只有女巫Vika能够应对。她拥有两种魔法能力——水魔法和火魔法。在一秒钟内,Vika可以生成w单位的水魔法和f单位的火魔法。她需要魔法来施放咒语。最初Vika拥有0单位的水魔法和0单位的火魔法。每个从传送门出现的怪兽都有自己的力量,用一个正整数表示。为了击败力量为s_i的第i只怪兽,Vika需要施放一个至少有相同力量的水咒语或火咒语。换句话说,Vika可以花费至少s_i单位的水魔法来施放一个水咒语,或者花费至少s_i单位的火魔法来施放一个火咒语。Vika可以立即创建和施放咒语。只要她有足够的魔法,她每秒可以施放无限数量的咒语。女巫想要尽快拯救世界,所以告诉她需要多少时间。
输入数据格式:
每个测试包含多个测试用例。每个测试的第一行包含一个整数t(1≤t≤100)——测试用例的数量。接下来是对测试用例的描述。
每个测试用例的第一行包含两个整数w、f(1≤w, f≤10^9)——Vika每秒可以生成的水魔法和火魔法的数量。
每个测试用例的第二行包含一个整数n(1≤n≤100)——怪兽的数量。
每个测试用例的第三行包含n个整数s_1, s_2, s_3, ..., s_n(1≤s_i≤10^4)——怪兽的力量。
保证所有测试用例的n之和不超过100。
输出数据格式:
对于每个测试用例,输出一个整数——Vika击败所有怪兽所需的最少秒数。题目大意: 一个黑暗力量的传送门在世界边界打开,整个世界都处于可怕威胁之中。为了关闭传送门并拯救世界,你需要击败从传送门出现的n只怪兽。只有女巫Vika能够应对。她拥有两种魔法能力——水魔法和火魔法。在一秒钟内,Vika可以生成w单位的水魔法和f单位的火魔法。她需要魔法来施放咒语。最初Vika拥有0单位的水魔法和0单位的火魔法。每个从传送门出现的怪兽都有自己的力量,用一个正整数表示。为了击败力量为s_i的第i只怪兽,Vika需要施放一个至少有相同力量的水咒语或火咒语。换句话说,Vika可以花费至少s_i单位的水魔法来施放一个水咒语,或者花费至少s_i单位的火魔法来施放一个火咒语。Vika可以立即创建和施放咒语。只要她有足够的魔法,她每秒可以施放无限数量的咒语。女巫想要尽快拯救世界,所以告诉她需要多少时间。 输入数据格式: 每个测试包含多个测试用例。每个测试的第一行包含一个整数t(1≤t≤100)——测试用例的数量。接下来是对测试用例的描述。 每个测试用例的第一行包含两个整数w、f(1≤w, f≤10^9)——Vika每秒可以生成的水魔法和火魔法的数量。 每个测试用例的第二行包含一个整数n(1≤n≤100)——怪兽的数量。 每个测试用例的第三行包含n个整数s_1, s_2, s_3, ..., s_n(1≤s_i≤10^4)——怪兽的力量。 保证所有测试用例的n之和不超过100。 输出数据格式: 对于每个测试用例,输出一个整数——Vika击败所有怪兽所需的最少秒数。