CF1862F.Magic Will Save the World

普及+/提高

通过率:0%

时间限制:4.00s

内存限制:256MB

AC君温馨提醒

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

题目描述

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 nn 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 ww units of water mana and ff units of fire mana. She will need mana to cast spells. Initially Vika have 00 units of water mana and 00 units of fire mana.

Each of the nn monsters that emerge from the portal has its own strength, expressed as a positive integer. To defeat the ii-th monster with strength sis_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 sis_i units of water mana on a water spell, or at least sis_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.

一道来自黑暗势力的传送门已在世界边界开启,整个世界正面临一场可怕的威胁。为了关闭传送门并拯救世界,你需要击败从传送门中依次出现的 nn 只怪物。

唯有女巫维卡能够应对这一危机。她掌握两种魔法力量——水系魔法与火系魔法。每秒钟,维卡可生成 ww 单位水系法力值与 ff 单位火系法力值。她需要消耗法力值来施放法术。初始时,维卡拥有 00 单位水系法力值与 00 单位火系法力值。

从传送门中出现的 nn 只怪物各自具有一个以正整数表示的力量值。要击败第 ii 只力量值为 sis_i 的怪物,维卡必须施放一个强度至少等于 sis_i 的水系法术或火系法术。换言之,维卡可消耗至少 sis_i 单位水系法力值来施放一个水系法术,或消耗至少 sis_i 单位火系法力值来施放一个火系法术。

维卡可以瞬间生成并施放法术。只要拥有足够的法力值,她每秒可施放任意数量的法术。

这位女巫希望以最短时间拯救世界,请告诉她所需最少时间。

输入格式

Each test consists of several test cases. The first line of each test contains a single integer tt (1≤t≤1001 \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 ww, ff (1≤w,f≤1091 \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 nn (1≤n≤1001 \le n \le 100) — the number of monsters.

The third line of each test case contains nn integers s1,s2,s3,…,sns_1, s_2, s_3, \dots, s_n (1≤si≤1041 \le s_i \le 10^4) — the strengths of the monsters.

It is guaranteed that the sum of nn over all test cases does not exceed 100100.

每个测试包含若干测试用例。每个测试的第一行包含一个整数 tt(1≤t≤1001 \le t \le 100),表示测试用例的数量。随后是各测试用例的描述。

每个测试用例的第一行包含两个整数 ww、ff(1≤w,f≤1091 \le w, f \le 10^9),分别表示维卡每秒可生成的水系法力值与火系法力值。

每个测试用例的第二行包含一个整数 nn(1≤n≤1001 \le n \le 100),表示怪物的数量。

每个测试用例的第三行包含 nn 个整数 s1,s2,s3,…,sns_1, s_2, s_3, \dots, s_n(1≤si≤1041 \le s_i \le 10^4),表示各怪物的强度。

保证所有测试用例中 nn 的总和不超过 100100。

输出格式

For each test case, output a single integer — the minimum time in seconds that Vika will need to defeat all the monsters.

对于每个测试用例,输出一个整数——Vika 击败所有怪物所需的最短时间(单位:秒)。

输入输出样例

  • 输入#1

    4
    2 3
    3
    2 6 7
    37 58
    1
    93
    190 90
    2
    23 97
    13 4
    4
    10 10 2 45

    输出#1

    3
    2
    1
    5

说明/提示

In the first sample, after the first second, Vika can spend 22 units of fire mana to kill the first monster. Then she has 22 units of water mana and 11 unit of fire mana. After the third second, she will have 66 units of water mana and 77 units of fire mana at her disposal. This will be enough to immediately kill the second and third monsters.

在第一个样例中,第一秒后,维卡可以消耗 22 点火焰法力值来消灭第一只怪物。此时她剩余 22 点水系法力值和 11 点火焰法力值。第三秒后,她将拥有 66 点水系法力值和 77 点火焰法力值,足以立即消灭第二只和第三只怪物。

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

首页