Problem A
Keeping the Dogs Apart

Shadow and Lydia have a particular walk they each prefer and know by heart. If you just let them out, they will follow their favorite walk, eventually ending up in their respective doghouses. Problem solved!
Sadly, you realize that if you just let both dogs out at the same time and let them do their walks on their own, they might get too close to each other. If they get too close, they will leave their favorite walk to “have some fun’’ and you are not sure you can find good homes for any more puppies. To ensure this does not happen, you need to calculate the minimum distance between the dogs when they are out walking on their own.
Both dogs start at the same time and keep exactly the same pace. Immediately after a dog arrives at its doghouse it stays inside and goes to sleep, so we no longer need to worry about the distance to the other dog, even though the other dog may still walk for a while longer. Note that a dog is still awake at the exact moment of entering its house and falls asleep immediately after entering.
Input
The first line of input consists of an integer
Output
Output the minimum distance between the two dogs during
their walks. The numbers should be accurate to an absolute or
relative error of at most
Sample Input 1 | Sample Output 1 |
---|---|
2 0 0 10 0 2 30 0 15 0 |
10 |
Sample Input 2 | Sample Output 2 |
---|---|
5 10 0 10 8 2 8 2 0 10 0 9 0 8 4 8 4 12 0 12 0 8 4 8 4 12 0 12 0 8 |
1.414213562373 |