Sprinklers
InterviewTime limit2sMemory limit512 MB
Place two fixed sprinklers and choose radii so every flower is covered, minimizing the sum of squared radii; print that minimum as an integer.
- Level
Medium5 of 10
- Topics
- Sorting, Greedy, Geometry, Brute force
- Solved
- No attempts yet
Problem
Youngsun grows flowers in her yard. She wants them to grow as naturally as possible, so she planted them here and there like weeds. She scattered them so widely that watering them became hard.
So Youngsun bought 2 sprinklers and installed them. The first sprinkler waters a circular area of radius , and the second waters a circular area of radius . Youngsun wants to adjust the two radii so that every flower gets water. A flower only needs water from at least one of the two sprinklers.
A flower at gets water from a sprinkler at with radius exactly when .
The watered area is , and Youngsun wants to make this value as small as possible to save water. For simplicity, ignore . Find the minimum value of such that every flower gets water.
Input
The first line contains the number of flowers and the sprinkler coordinates , , , . The first sprinkler is at and the second is at . (, )
Each of the next lines contains the coordinates , of one flower. ()
All flower and sprinkler coordinates are pairwise distinct.
Output
Print the minimum value of as an integer. A radius may be .