Problem Statement |
| You are given a set of white points on a plane, with the x and y coordinates of the i-th point represented by the i-th elements of pointsX and pointsY, respectively. You play a game with your friend alternating turns. On your turn, you pick any white point and color it red. On his turn, your friend picks any white point and colors it blue. The game ends when there are no white points left, and the final score is the sum of all distances between pairs of points with different colors. Knowing that you make the first turn, and that your opponent plays optimally and wants to minimize the final score, return the highest final score you can achieve. |
|
Definition |
| Class: | PointsGame | Method: | gameValue | Parameters: | int[], int[] | Returns: | double | Method signature: | double gameValue(int[] pointsX, int[] pointsY) | (be sure your method is public) |
|
|
|
|
Notes |
- | Your return must have relative or absolute error less than 1E-9. |
|
Constraints |
- | pointsX will contain between 2 and 12 elements, inclusive.
|
- | pointsY will contain the same number of elements as pointsX.
|
- | Each element of pointsX and pointsY will be between 0 and 1000, inclusive.
|
- | All points in the given set will be distinct. |
|
Examples |
0) | |
| | Returns: 1.0 | There are only 2 points and the answer is the distance between them. |
|
|
1) | |
| | Returns: 12.198039027185569 | Your friend can always choose the closest point to get the smallest answer. |
|
|
2) | |
| |
3) | |
| |