Last One Standing
InterviewTime limit2sMemory limit1024 MB
Two units fire missiles at fixed reload intervals with a 0.5 second delay; find which player's unit is destroyed first, or whether both fall at the same moment.
- Level
Easy3 of 10
- Topics
- Math, Implementation
- Solved
- No attempts yet
Problem
In a computer game, each unit is described by its health , damage , and time to reload .
When a unit fires a missile at an opposing unit, the opponent's health decreases by 0.5 seconds after the missile is fired. The time between consecutive missile launches by the same unit must be at least seconds.
For simplicity, the missile supply is infinite for all units in the game.
Two players fight in this game. The first player controls a unit with health , damage , and reload time . The second player controls a unit with health , damage , and reload time . Both units are fully reloaded at the start of the fight, so they can fire missiles immediately.
A unit is destroyed when its health becomes zero or negative. A player wins if there is a moment when the opponent's unit is destroyed while their own unit is not.
A missile takes 0.5 seconds to reach its target. Both units can fire at the same time and destroy each other.
Determine who wins when both players act optimally.
Input
One line contains the integers , , and ().
The second line contains the integers , , and ().
Output
Print player one if the first player wins, player two if the second player wins, or draw if neither player wins.