#P14125. [SCCPC 2021] Monster Hunter
[SCCPC 2021] Monster Hunter
题目描述
Ema is the best carry player in a game. In the game, she needs to eliminate monsters. The -th monster has health points (HP) at the beginning. When a monster is attacked by Ema, its HP is reduced by her attack power. When the HP of a monster is less than or equal to , the monster is eliminated.
To make the game more interesting, the attack power is not a constant number. There is a basic attack sequence , and the damage caused is generated by repeating this sequence. Formally, let be the damage caused by the -th attack, we have
$$r_{i}= \left \{ \begin{array}{ll} a_i & 1 \le i \le n \\ r_{i - n} & i > n \end{array} \right. $$To eliminate the monsters as soon as possible, Ema wants to minimize the number of attacks. Can you tell her the minimum number of attacks required to eliminate all the monsters?
输入格式
There are multiple test cases. The first line of the input contains an integer indicating the number of test cases. For each test case:
The first line contains an integer () indicating the length of the basic attack sequence.
The second line contains integers () indicating the basic attack sequence.
The third line contains an integer () indicating the number of monsters.
The fourth line contains integers () where indicates the initial HP of the -th monster.
It's guaranteed that neither the sum of nor the sum of of all test cases will exceed .
输出格式
For each test case output one line containing one integer indicating the minimum number of attacks to eliminate all the monsters.
2
2
3 2
3
2 4 2
5
1 2 3 2 1
2
3 3
4
3
提示
For the first example, the damage sequence is . We can attack monsters 1, 2, 3 and 2 in order to eliminate all the monsters.
For the second example, we can attack monsters 2, 2, 1 in order.