#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1e18
#define eps 1e-9

class Point {
   public:
    long double x, y;
    constexpr Point(long double x = 0, long double y = 0) : x(x), y(y) {}

    constexpr Point operator+(const Point p) { return Point(*this) += p; }
    constexpr Point operator-(const Point p) { return Point(*this) -= p; }
    constexpr Point operator*(const long double a) { return Point(*this) *= a; }
    constexpr Point operator/(const long double a) { return Point(*this) /= a; }
    constexpr Point &operator+=(const Point p) {
        x += p.x;
        y += p.y;
        return *this;
    }
    constexpr Point &operator-=(const Point p) {
        x -= p.x;
        y -= p.y;
        return *this;
    }
    constexpr Point &operator*=(const long double a) {
        x *= a;
        y *= a;
        return *this;
    }
    constexpr Point &operator/=(const long double a) {
        x /= a;
        y /= a;
        return *this;
    }

    constexpr Point e() { return Point(*this) / dist(); }
    constexpr long double dist(const Point &p = Point(0, 0)) { return hypot(x - p.x, y - p.y); }
    constexpr long double arg() { return atan2(x, y); }

    friend std::istream &operator>>(std::istream &in, Point &m) {
        long double a, b;
        in >> a >> b;
        m.x = a, m.y = b;
        return in;
    }
};

class Circle {
   private:
   public:
    Point center;
    long double r;

    constexpr Circle(const Point p = {0, 0}, const long double r = 0) : center(p), r(r) {}

    constexpr bool contain(Circle &c) { return center.dist(c.center) + c.r < r + eps; }
    constexpr bool contain(Point &p) { return center.dist(p) < r + eps; }
    constexpr bool on(Point &p) { return fabs(center.dist(p) - r) < eps; }
    constexpr uint8_t intersects(Circle &c) {
        if (c.r + r < center.dist(c.center) + eps || c.contain(*this) || contain(c)) return 0;
        if (fabs(c.r + r - center.dist(c.center)) < eps ||
            fabs(fabs(c.r - r) - center.dist(c.center)) < eps)
            return 1;
        return 2;
    }
    const vector<Point> intersectsAt(Circle &c) {
        if (intersects(c) == 0) return vector<Point>(0);
        if (intersects(c) == 1) {
            Point c1 = c.center - center;
            long double d = c1.dist() * c1.dist();
            long double a = (d + r * r - c.r * c.r) / 2;
            return {center + c1 * a / d};
        } else {
            Point c1 = c.center - center;
            long double d = c1.dist() * c1.dist();
            long double a = (d + r * r - c.r * c.r) / 2;
            long double x1, y1, x2, y2;
            x1 = (a * c1.x + c1.y * sqrt(d * r * r - a * a)) / d;
            x2 = (a * c1.x - c1.y * sqrt(d * r * r - a * a)) / d;
            y1 = (a * c1.y - c1.x * sqrt(d * r * r - a * a)) / d;
            y2 = (a * c1.y + c1.x * sqrt(d * r * r - a * a)) / d;
            return {center + Point{x1, y1}, center + Point{x2, y2}};
        }
    }
    friend std::istream &operator>>(std::istream &in, Circle &m) {
        long double a, b, c;
        in >> a >> b >> c;
        m.center = {a, b};
        m.r = c;
        return in;
    }
};

int N, K;
vector<Point> meat;
vector<int> c;

bool solve(long double T) {
    vector<Circle> area(N);
    vector<Point> cp;
    for (int i = 0; i < N; i++) area[i] = Circle(meat[i], T / c[i]);

    for (int i = 0; i < N; i++) {
        cp.push_back(area[i].center);
        for (int j = i + 1; j < N; j++)
            for (auto &p : area[i].intersectsAt(area[j])) cp.push_back(p);
    }
    for (auto &p : cp) {
        int cnt = 0;
        for (auto &C : area)
            if (C.contain(p) || C.on(p)) cnt++;
        if (cnt >= K) return true;
    }
    return false;
}

long double binary_search(long double ok, long double ng) {
    while (abs(ok - ng) > 1e-10) {
        long double mid = (ok + ng) / 2;
        if (solve(mid)) {
            ok = mid;
        } else {
            ng = mid;
        }
    }
    return ok;
}

int main() {
    cin >> N >> K;
    meat.resize(N);
    c.resize(N);
    for (int i = 0; i < N; i++) {
        cin >> meat[i] >> c[i];
    }
    cout << setprecision(8) << binary_search(1e9, 0) << endl;
    return 0;
}

Measured memory_bytes: 432