Problem:
Score : 600 points

Problem Statement

Takahashi wants to grill N pieces of meat on a grilling net, which can be seen as a two-dimensional plane. The coordinates of the i-th piece of meat are \left(x_i, y_i\right), and its hardness is c_i.

Takahashi can use one heat source to grill the meat. If he puts the heat source at coordinates \left(X, Y\right), where X and Y are real numbers, the i-th piece of meat will be ready to eat in c_i \times \sqrt{\left(X - x_i\right)^2 + \left(Y-y_i\right)^2} seconds.

Takahashi wants to eat K pieces of meat. Find the time required to have K or more pieces of meat ready if he put the heat source to minimize this time.

Constraints

All values in input are integers.

1 \leq N \leq 60

1 \leq K \leq N

-1000 \leq x_i , y_i \leq 1000

\left(x_i, y_i\right) \neq \left(x_j, y_j\right) \left(i \neq j \right)

1 \leq c_i \leq 100

Input

Input is given from Standard Input in the following format:

N K
x_1 y_1 c_1
\vdots
x_N y_N c_N

Output

Print the answer.

It will be considered correct if its absolute or relative error from our answer is at most 10^{-6}.

Sample Input 1

4 3
-1 0 3
0 0 3
1 0 2
1 1 40

Sample Output 1

2.4

If we put the heat source at \left(-0.2, 0\right), the 1-st, 2-nd, and 3-rd pieces of meat will be ready to eat within 2.4 seconds. This is the optimal place to put the heat source.

Sample Input 2

10 5
-879 981 26
890 -406 81
512 859 97
362 -955 25
128 553 17
-885 763 2
449 310 57
-656 -204 11
-270 76 40
184 170 16

Sample Output 2

7411.2252

Solution in C++14 (GCC 5.4.1) (judge verdict: Wrong Answer)

#include <iostream> // cin, cout, cerr
#include <algorithm> // minmax, sort, swap
#include <numeric> // iota
#include <cstdio> // printf, scanf
#include <string> // string, stoi, to_string
#include <vector> // vector
#include <queue> // queue, priority_queue
#include <deque> // deque
#include <map> // key-value pairs sorted by keys
#include <set> // set
#include <iomanip> // cout<<setprecision(n)
#include <functional> // function<void(int)>
#include <cmath>

#ifdef DEBUG
#include "debug.hpp"
#else
#define debug(...)
#endif

#define int long long // at least int64 > 9*10^18
#define ENDL '\n'
#define rep(i,n) for(int i = 0; i < (n); i++)
#define print(i) std::cout << (i) << '\n'
#define all(v) (v).begin(), (v).end()
/* libraries */

struct Point
{
	long double x,y,c;
	Point() {}
	Point(long double x, long double y, long double c) : x(x),y(y),c(c) {}
	long double dist(Point a) {
		long double dx = a.x-x;
		long double dy = a.y-y;
		return std::sqrt(dx*dx+dy*dy);
	}
};

signed main() {
	int n,k;
	std::cin >> n >> k;
	std::vector<Point> points(n);
	for(auto&p:points) std::cin >> p.x >> p.y >> p.c;
	if(k==1) {
		print(0);
		return 0;
	}
	long double l=0,r=4e5+1;
	while(r-l>1e-8) {
		long double mid = (l+r)/(long double)2;
		std::vector<Point> inter=points;
		rep(i,n) rep(j,n) if(i!=j) {
			Point p0=points[i],p1=points[j];
			long double r0 = mid/p0.c;
			long double r1 = mid/p1.c;
			if(p0.dist(p1)>r1+r0) continue;
			if(p0.dist(p1)+r0<r1) continue;
			if(p0.dist(p1)+r1<r0) continue;
			long double a,h,d,x0,x1,y0,y1,x2,y2,x3,y3;
			x0=p0.x;y0=p0.y;x1=p1.x;y1=p1.y;
			d=std::sqrt(std::pow(x1-x0,2) + std::pow(y1-y0,2));
			a=(std::pow(r0,2)-std::pow(r1,2)+std::pow(d,2))/(2*d);
			h=std::sqrt(std::pow(r0,2)-std::pow(a,2));
			x2=x0+a*(x1-x0)/d;
			y2=y0+a*(y1-y0)/d;
			x3=x2+h*(y1-y0)/d;       // also x3=x2-h*(y1-y0)/d
			y3=y2-h*(x1-x0)/d;       // also y3=y2+h*(x1-x0)/d
			inter.emplace_back(x3,y3,0);
			x3=x2-h*(y1-y0)/d;       // also x3=x2-h*(y1-y0)/d
			y3=y2+h*(x1-x0)/d;       // also y3=y2+h*(x1-x0)/d
			inter.emplace_back(x3,y3,0);
		}
		int max = 0;
		for(auto p:inter) {
			int count = 0;
			rep(i,n) if(p.dist(points[i])<=mid/points[i].c) count++;
			max = std::max(max,count);
		}
		if(max>=k) r=mid;
		else l=mid;
	}
	std::cout << std::setprecision(10) << r << ENDL;
	return 0;
}