#B4027. Sensing the Twin: When Will They Reunite?
Sensing the Twin: When Will They Reunite?
Sensing the Twin: When Will They Reunite?
Two twins, Violet and Blue, who got separated in an amusement park, have a special power: after being apart for a certain duration, they can sense each other's location if they are within a certain distance. Specifically:
- Violet starts sensing when the separation time is at least \(t_1\) minutes. She can sense Blue if their distance does not exceed \(d_1\).
- Blue starts sensing when the separation time is at least \(t_2\) minutes. She can sense Violet if their distance does not exceed \(d_2\).
The twins are currently separated for \(t\) minutes and the distance between them is \(d\). They are waiting in place. Determine the minimum additional minutes they need to wait until at least one of them can sense the other. If it is impossible for either to sense the other regardless of the waiting time, output -1
.
Note: The twins' positions remain unchanged while waiting, so the distance stays constant.
inputFormat
The input consists of a single line with six space-separated integers:
- \(t_1\): the minimum minutes Violet needs before she can sense.
- \(d_1\): the maximum distance within which Violet can sense Blue.
- \(t_2\): the minimum minutes Blue needs before she can sense.
- \(d_2\): the maximum distance within which Blue can sense Violet.
- \(t\): the current separation time in minutes.
- \(d\): the current distance between the twins.
outputFormat
Output a single integer representing the minimum additional minutes required for at least one twin to sense the other. If it is impossible, output -1
.
sample
10 100 12 80 9 90
1