DWITE '11 R1 #3 - Take a Walk

View as PDF

Submit solution

Points: 10
Time limit: 1.0s
Memory limit: 64M

Problem type
DWITE, 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 1^\text{st}, to the 2^\text{nd}, then to the 3^\text{rd}, and so on. Even though he isn't allowed to go to the store, Little Billy wants to know the closest distance he gets to the store on his way home. Being his only imaginary friend who knows how to program, help him by computing this distance.

There will be 5 sets of input. The first line of each set contains a number 1 \le N \le 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, -1\,000 \le X, Y \le 1\,000, the coordinates of points for the walk. The last line of each set contains two numbers separated by a single space, -1\,000 \le C_x, C_y \le 1\,000, the location of the forbidden candy store.

For each set, output one line, the closest distance to the candy store, from anywhere along the walk. Round to 2 decimal places. Print trailing zeros. E.g. 1.00.

Sample Input

3
0 0
0 1
1 3
1 1

Sample Output

0.89

Problem Resource: DWITE

Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported

Comments

There are no comments at the moment.