#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<pair<ll,pair<ll,ll>>> ii;
#define pb push_back
#define ff first
#define ss second
//For geometric calculations, try to use these kind of constructs


// Creating a structure point, having coordinates and distance
struct Point {
    double x, y;
    // a function that does not modify the struct
	double distance(const Point& that) const;
};



// for finding Angle 
struct Angle {
	double sin, cos;
	Angle operator-()const {
		return Angle{ -sin, cos };
	}
};


// Creating struct Vector
struct Vector {
	double dx, dy;
	Vector rotate(const Angle angle) const {
		return Vector{ dx * angle.cos - dy * angle.sin, dy * angle.cos + dx * angle.sin };
	}
	double length() const {
		return  sqrt(dx * dx + dy * dy);
	}
	Vector change_length(const double new_length) const {
		const auto current = length();
		return Vector{ dx / current * new_length, dy / current * new_length };
	}
};
 

// operator - for Vector 
Vector operator-(const Point a, const Point b) {
	return Vector{ a.x - b.x, a.y - b.y };
}


// operator + for Vector
Point operator+(const Point a, const Vector v)
{
	return Point{ a.x + v.dx, a.y + v.dy };
}


//
struct Circle {
	Point center;
	double radius;
 
};


//
Angle angle_of(double opposite, double a, double b) {
	double cos = (a * a + b * b - opposite * opposite) / (2 * a * b);
	return Angle{  sqrt(1 - cos * cos), cos };
}
 

//
bool has_intersection(const Circle& a, const Circle& b) {
	return a.center.distance(b.center) <= a.radius + b.radius;
}


//
bool is_contains(const Circle& outer, const Circle& inner) {
	if (outer.radius < inner.radius) return false;
	return outer.center.distance(inner.center) + inner.radius <= outer.radius;
}


//
vector<Point> cross_point(const Circle a, const Circle b) {
	if (!has_intersection) return {};
	if (is_contains(a, b)) return { b.center };
 	if (is_contains(b, a)) return { a.center };
	const auto angle = angle_of(b.radius, a.radius, a.center.distance(b.center));
	const auto vec = (b.center - a.center).change_length(a.radius);
	return { a.center + vec.rotate(angle), a.center + vec.rotate(-angle) };
}


//
int count_circle(const Point target, const  vector<Circle>& circles) {
	int count = 0;
	for (const auto c : circles) {
		if (c.center.distance(target) <= c.radius + 1e-6) {
			++count;
		}
	}
	return count;
}


//
vector<Point> cross_points(const  vector<Circle>& circles) {
	 vector<Point> points;
	for (auto i = 0; i < circles.size(); ++i) {
		for (auto j = 0; j < circles.size(); ++j) {
			for (const auto cp : cross_point(circles[i], circles[j])) {
				points.push_back(cp);
			}
		}
	}
	return points;
}


//
struct Meet {
	Point position;
	double headness;
};


//
vector<Circle> to_circles(double time, const  vector<Meet>& meets) {
	 vector<Circle> result; result.reserve(meets.size());
	for (const auto& m : meets) {
		result.push_back(Circle{ m.position, time / m.headness});
	}
	return result;
}


//
bool can_make(int count, double time, const  vector<Meet>& meat) {
	const auto circles = to_circles(time, meat);
	for (const auto cp : cross_points(circles)) {
		if (count_circle(cp, circles) >= count) return true;
	}
	return false;
}


int main() {
	int n, k;
    cin >> n >> k;
	vector<Meet> meets(n);
	for (auto& m : meets) 
        cin >> m.position.x >> m.position.y >> m.headness;  // m.headness == cost
	double min = 0, max = 1000000;
	for (auto i = 0; i < 100; ++i) {
		const auto mid = (min + max) / 2;
		if (can_make(k, mid, meets)) {
			max = mid;
		}
		else {
			min = mid;
		}
	}
	cout << setprecision(7) << fixed << max << endl;
}

//returns the distance of given point from another
double Point::distance(const Point& that) const {
	return ((*this) - that).length();
}


Measured memory_bytes: 548