Enemy Towers
In complex strategy games, determining the optimal strategy to defeat your opponent is crucial. In this scenario, you are facing an opponent who has numWodT wooden towers and numStoT stone towers. Each tower possesses hpT hit points. You command myUnits soldiers, and each soldier can only attack one type of tower. Your task is to divide your soldiers into two groups: one group will exclusively attack wooden towers, while the other will focus solely on stone towers. Once the game begins, soldiers cannot switch groups (i.e., soldiers assigned to attack wooden towers cannot be reassigned to attack stone towers, and vice versa).
During each round of attacks, the following occurs:
Each soldier in the first group attacks a wooden tower, inflicting 1 point of damage. You can independently select which tower each soldier attacks.
Each soldier in the second group attacks a stone tower, also inflicting 1 point of damage. You can independently select which tower each soldier attacks.
Your opponent retaliates: wooden towers will eliminate w · attackT of your soldiers from the first group, where w is the number of wooden towers still standing. Similarly, stone towers will eliminate c · attackT of your soldiers from the second group, where c is the number of stone towers still standing.
Your objective is to calculate the minimum number of rounds needed to destroy all towers. If it is impossible to achieve this, output -1.
Input
You will receive five numbers: myUnits, hpT, attackT, numWodT, numStoT (1 ≤ myUnits ≤ 10^9
, 1 ≤ hpT, attackT, numWodT, numStoT ≤ 40000).
Output
Output the minimum number of rounds required to destroy all towers, or -1 if it is impossible.