DWITE Online Computer Programming Contest

Take a Walk

October 2011
Problem 3

Like any other 10-year-old, Little Billy loves to eat candy. However, every day after school, his parents give him a specific path he has to take home to make sure he doesn’t go to the candy store. Billy is given a number of points, starting at his school and ending at home, and he walks directly from the 1st to the 2nd, then to the 3rd, and so on. Even though he isn’t allowed to go to the store, Little Billy wants to know the closest distance from the store while on his way home. Being his only imaginary friend who knows how to program, help him by computing this distance.

The input file DATA3.txt will contain 5 sets of input. The first line of each set contains an integer 1 ≤ N ≤ 10, the number of points on Little Billy’s walk back home. The next N lines each contain two numbers separated by a single space, −1000 ≤ X, Y ≤ 1000, the coordinates of points for the walk. The last line of each set contains two numbers separated by a single space, −1000 ≤ Cx, Cy ≤ 1000, the location of the forbidden candy store.

The output file OUT3.txt will contain 5 lines of output, each being the closest distance to the candy store for that input case. The distance is among any point along the walk; round to 2 decimal places and print trailing zeros (e.g. 1.00).

Sample Input (only first case shown):
```3
0 0
0 1
1 3
1 1```
Sample Output (only first case shown):
`0.89`