| ||As a serious strategy-games player, you decided to solve one of the most common problems - attacking your
opponent's guard towers. |
Before the attack, you've got myUnits soldiers. Each soldier in a single round inflicts 1 hit point of damage to one of the towers.
Your opponent doesn't have any soldiers. However, he's got numT towers with hpT hit points each. Each tower kills attackT of your soldiers per round.
The course of one round:
1. Each soldier in your army attacks a tower of your choice for 1 hit point of damage. When a tower loses all its hit points, it is destroyed. You can pick the tower independently for each soldier.
2. Your opponent attacks. He will kill k*attackT of your soliders, where k is the number of remaining towers.
Your task is to destroy all the towers. If it is possible, return the minimum number of rounds you need to do this.
Otherwise return -1.
|Parameters:||int, int, int, int|
|Method signature:||int attack(int myUnits, int hpT, int attackT, int numT)|
|(be sure your method is public)|
|-||More than one soldier can attack the same tower in the same round.|
|-||myUnits will be between 1 and 1000000, inclusive.|
|-||hpT, attackT, numT will each be between 1 and 10000, inclusive.|
- Your soldiers destroy 6 towers leaving one tower with 1 hit point and one tower with 2 hit points.
- Your opponent attacks and kills 2*3=6 of your soldiers.
- You have 7 soldiers remaining, which is more than enough to take out the 3 hit points of the remaining towers.