| ||As a serious strategy-games player, you often need to find the best strategy for destroying your opponents' guard towers. You are currently preparing to play a game where your opponent has numWodT wooden towers and numStoT stone towers. Each tower has hpT hit points, and once a tower loses all its hit points, it is destroyed. You have myUnits soldiers. Because different weapons are required to destroy different types of towers, you must divide your soldiers into two groups. The first group will attack only wooden towers and the second group will attack only stone towers. You can divide your soldiers up however you like, but once the game begins, you are not allowed to re-assign them to different groups.|
In each round of attacks, the following happens:
1. Each soldier from the first group attacks a single wooden tower and inflicts 1 hit point of damage. You can pick the tower independently for each soldier.
2. Each solider from the second group attacks a single stone tower and inflicts 1 hit point of damage. You can pick the tower independently for each soldier.
3. Your opponent attacks. The wooden towers will kill w*attackT of your soldiers from the first group, where w is the number of remaining wooden towers, and the stone towers will kill s*attackT of your soldiers from the second group, where s is the number of remaining stone towers.
Return the minimum number of rounds required to destroy all the towers, or return -1 if it is impossible.
|Parameters:||int, int, int, int, int|
|Method signature:||int attack(int myUnits, int hpT, int attackT, int numWodT, int numStoT)|
|(be sure your method is public)|
|-||More than one soldier can attack the same tower.|
|-||myUnits will be between 1 and 1000000000, inclusive.|
|-||hpT, attackT, numWodT, numStoT will be each between 1 and 40000, inclusive.|
|Put 3 soldiers in the first group and 4 soldiers in the second group.|
First group: Your soldiers destroy one wooden tower and leave the second tower with 1 hit point.
Second group: Your soldiers destroy two stone towers.
The one remaining wooden tower kills one of your soldiers in the first group, and the one remaining stone tower kills one of your soldiers in the second group.
First group: You have 2 soldiers remaining in the first group, and that's more than enough to destroy the last wooden tower.
Second group: You have 3 soldiers remaining in the second group, and that's also more than enough to destroy the last stone tower.
|Towers are really powerful but luckily you have exactly enough soldiers to destroy them before they attack.|
|Put 126 soldiers in the first group and 74 soldiers in the second group.|