Weighted points
Easy
Execution time limit is 20 seconds
Runtime memory usage limit is 64 megabytes
You have N points on 2-d plane. Coordinates of each point P_i are (x_i, y_i). Each point has a weight w_i associated with it. Given a point X, we define the distance function F as
Here D(X,P_i) denotes the Euclidean distance between X and point P_i.
Find a point X such that distance function F(x) is minimized. Output the minimum value of F(x).
Input
First line contains T, the number of test cases. First line of each test case contains N, the number of points. Each of the next N lines contains three space separated integers x_i, y_i and w_i respectively.
It is known that T ≤ 20, N ≤ 1000, 0 ≤ x_i, y_i, w_i ≤ 1000.
Output
Output contains T lines, each containing minimum value of F(x) rounded to 3 decimal places.
Examples
Input #1
Answer #1
Submissions 80
Acceptance rate 23%