Problem Statement | |||||||||||||
As a serious strategy-games player, you decided to solve one of the most common problems - attacking your
opponent's building (barracks), which constantly produces new soldiers. Before the attack, you've got myUnits soldiers. In a single round, each soldier can either kill one of your opponent's soldiers or inflict 1 hit point of damage to the barracks. Your opponent doesn't have any soldiers initially. However, his barracks has barHp hit points and produces unitsPerRound soldiers per round. The course of one round: 1. Each solider from your army either kills one of your opponent's soldiers or inflicts 1 hit point of damage to the barracks. Each soldier can choose to do something different. When the barracks loses all of its hit points, it is destroyed. 2. Your opponent attacks. He will kill k of your soldiers, where k is the number of remaining soldiers he has. 3. If the barracks are not yet destroyed, your opponent will produce unitsPerRound new soldiers. Your task is to destroy the barracks and kill all your opponent's soldiers. If it is possible, return the minimum number of rounds you need to do this. Otherwise return -1. | |||||||||||||
Definition | |||||||||||||
| |||||||||||||
Constraints | |||||||||||||
- | myUnits, barHp, unitsPerRound will each be between 1 and 50, inclusive. | ||||||||||||
Examples | |||||||||||||
0) | |||||||||||||
| |||||||||||||
1) | |||||||||||||
| |||||||||||||
2) | |||||||||||||
| |||||||||||||
3) | |||||||||||||
|