Heroes of Might

아직 제출이 없습니다시간 제한3초메모리 제한512 MB

문제

Recently, Hellen played her favorite game "Heroes of Might". She had a hero with only one Rust dragon, which was attacked by another hero with a lot of peasants. Another hero had nn groups of peasants, ii-th of them had a_ia\_i peasants in it. Unfortunately, Hellen lost that battle, but now she is wondering how big the health of the Rust dragon should be to win against such a big army of peasants?

Let's discuss how the battle goes. Initially, the Rust dragon has h_dh\_d health points, and each peasant has h_ph\_p health points. So ii-th group of peasants has a total of H=h_pa_iH = h\_p \cdot a\_i health points at the start of the battle. The battle consists of several rounds. In each round, two things happen:

  • First, the dragon chooses one group of peasants and attacks it. The health of that group is decreased by the dragon's damage rating dd. If the group has zero or less health points, it is destroyed and is removed from the game.
  • Second, each one of the peasant groups attacks the dragon. A group with the total current health HH has Hh_p\lceil\frac{H}{h\_p}\rceil peasants still alive and each of them decreases the dragon's health by one.

If the dragon's health becomes zero or less at any point, it dies and Hellen loses. If all peasant groups are destroyed, Hellen wins the battle.

You need to determine the smallest possible h_dh\_d, which could make Hellen win if she chooses targets on each turn optimally.

입력

The first line of the input contains an integer tt (1t10001 \le t \le 1000) --- the number of test cases you need to solve.

Each of the test cases is described by two lines. The first line contains three numbers nn (1n10001 \le n \le 1000), dd (1d1091 \le d \le 10^9), and h_ph\_p (1h_p1091 \le h\_p \le 10^9) --- the number of peasant groups, the dragon's damage rating, and the health of each peasant. The second line contains nn numbers a_ia\_i (1a_i109;h_pa_i1091 \le a\_i \le 10^9; h\_p \cdot \sum{a\_i} \le 10^9) --- the number of peasants in each group.

The sum of nn over all test cases does not exceed 10001000.

출력

For each test case, output one number --- the smallest amount of health h_dh\_d that the dragon should have for Hellen to win the battle. If the dragon is never attacked by a peasant, it should still have positive health, so output 1 in this case.

힌트

In the third test case, the optimal Hellen's strategy leads to the following battle. At the start, the dragon has h_d=26h\_d=26 health points, and two groups of peasants have H_1=410H\_1=4\cdot10 and H_2=510H\_2=5\cdot10 health points. We'll denote them as H_1=40(4)H\_1=40(4) and H_2=50(5)H\_2=50(5), placing the value of Hh_p\lceil\frac{H}{h\_p}\rceil in the brackets.

h_d=26h\_d=26, H_1=40(4)H\_1=40(4), H_2=50(5)H\_2=50(5)Round 1The dragon attacks the first group, dealing 1515 damage, leaving H_1=25(3)H\_1=25(3).
h_d=26h\_d=26, H_1=25(3)H\_1=25(3), H_2=50(5)H\_2=50(5)Peasants attack the dragon, dealing 3+53+5 damage, leaving h_d=18h\_d=18.
h_d=18h\_d=18, H_1=25(3)H\_1=25(3), H_2=50(5)H\_2=50(5)Round 2The dragon attacks the first group, dealing 1515 damage, leaving H_1=10(1)H\_1=10(1).
h_d=18h\_d=18, H_1=10(1)H\_1=10(1), H_2=50(5)H\_2=50(5)& Peasants attack the dragon, dealing 1+51+5 damage, leaving h_d=12h\_d=12.
h_d=12h\_d=12, H_1=10(1)H\_1=10(1), H_2=50(5)H\_2=50(5)Round 3The dragon attacks the second group, dealing 1515 damage, leaving H_2=35(4)H\_2=35(4).
h_d=12h\_d=12, H_1=10(1)H\_1=10(1), H_2=35(4)H\_2=35(4)Peasants attack the dragon, dealing 1+41+4 damage, leaving h_d=7h\_d=7.
h_d=7h\_d=7, H_1=10(1)H\_1=10(1), H_2=35(4)H\_2=35(4)Round 4The dragon attacks the second group, dealing 1515 damage, leaving H_2=20(2)H\_2=20(2).
h_d=7h\_d=7, H_1=10(1)H\_1=10(1), H_2=20(2)H\_2=20(2)Peasants attack the dragon, dealing 1+21+2 damage, leaving h_d=4h\_d=4.
h_d=4h\_d=4, H_1=10(1)H\_1=10(1), H_2=20(2)H\_2=20(2)Round 5The dragon attacks the second group, dealing 1515 damage, leaving H_2=5(1)H\_2=5(1)
h_d=4h\_d=4, H_1=10(1)H\_1=10(1), H_2=5(1)H\_2=5(1)Peasants attack the dragon, dealing 1+11+1 damage, leaving h_d=2h\_d=2.
h_d=2h\_d=2, H_1=10(1)H\_1=10(1), H_2=5(1)H\_2=5(1)Round 6The dragon attacks the second group, destroying it, so it is removed from the game.
h_d=2h\_d=2, H_1=10(1)H\_1=10(1)Peasants attack the dragon, dealing 11 damage, leaving h_d=1h\_d=1.
h_d=1h\_d=1, H_1=10(1)H\_1=10(1)Round 7The dragon attacks the first group, destroying it, so it is removed from the game.
h_d=1h\_d=1Game overThe dragon is still alive, Hellen wins.