#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
using ll = long long;

constexpr double eps = 1e-7;

struct Vec {
    static constexpr int N = 2;
    Vec() {}
    Vec(double x0, double x1) : x{ x0, x1 } {}
    double norm() const {
        double r = 0;
        for (int i = 0; i < N; i++) {
            r += x[i] * x[i];
        }
        return sqrt(r);
    }
    double inner(const Vec &v) const {
        double t = 0;
        for (int i = 0; i < N; i++) {
            t += x[i] * v.x[i];
        }
        return t;
    }
    Vec &rot90() {
        auto t = x[0];
        x[0] = x[1];
        x[1] = -t;
        return *this;
    }
    Vec &operator+=(const Vec &v) {
        for (int i = 0; i < N; i++) {
            x[i] += v.x[i];
        }
        return *this;
    }
    Vec &operator-=(const Vec &v) {
        for (int i = 0; i < N; i++) {
            x[i] -= v.x[i];
        }
        return *this;
    }
    Vec &operator*=(double t) {
        for (int i = 0; i < N; i++) {
            x[i] *= t;
        }
        return *this;
    }
    Vec operator+(const Vec &v) const {
        Vec r;
        for (int i = 0; i < N; i++) {
            r[i] = x[i] + v.x[i];
        }
        return r;
    }
    Vec operator-(const Vec &v) const {
        Vec r;
        for (int i = 0; i < N; i++) {
            r[i] = x[i] - v.x[i];
        }
        return r;
    }
    Vec operator*(double t) const {
        Vec r;
        for (int i = 0; i < N; i++) {
            r[i] = x[i] * t;
        }
        return r;
    }
    double &operator[](int i) {
        return x[i];
    }
    double x[N];
};

struct Line {
    Line() {}
    Line(Vec o, Vec v) : o(o), v(v) {}
    int intersect(const Line &l, Vec &v) const {
        Vec v0 = this->v;
        Vec v1 = l.v; v1.rot90();
        double t = v0.inner(v1);
        if (abs(t) < eps) return 0;

        v = o + v0 * (v1.inner(l.o - o) / t);
        return 1;
    }
    Vec o, v;
};

struct Circle {
    Circle() {}
    Circle(Vec o, double r) : o(o), r(r) {}
    int intersect(const Circle &c, Vec (&v)[2]) const {
        Vec v0 = c.o - o;
        double u = v0.norm();
        if (u < eps) return 0;
        double t = (r * r - c.r * c.r + u * u) / (u * 2);
        double s = r * r - t * t;
        if (s < -eps) return 0;
        if (s < eps) s = 0; else s = sqrt(s);
        v0 *= 1 / u;
        Vec v1 = v0; v1.rot90();
        v0 *= t;
        v1 *= s;
        v0 += o;
        for (int h = 0; h < 2; h++) {
            v[h] = v0 + v1;
            v1 *= -1;
        }
        return 2 - (s == 0.0);
    }
    int intersect(const Line &l, Vec (&v)[2]) const {
        Vec v1 = l.v;
        Vec v0 = v1; v0.rot90();
        Line l1 = { o, v0 };
        Vec a;
        if (l.intersect(l1, a) == 0) return 0;
        double t = (a - o).norm();
        double s = r * r - t * t;
        if (s < -eps) return 0;
        if (s < eps) s = 0; else s = sqrt(s);
        v1 *= s / v1.norm();
        for (int h = 0; h < 2; h++) {
            v[h] = a + v1;
            v1 *= -1;
        }
        return 2 - (s == 0);
    }
    Vec o;
    double r;
};

struct P {
    bool operator<(const P &p) const {
        return c < p.c;
    }
    Vec v;
    int c;
};

struct CL {
    Circle c;
    Line l;
    int i;
};

int main() {
    int n, k;
    cin >> n >> k;

    vector<P> p(n);
    for (int i = 0; i < n; i++) {
        int x, y, c;
        cin >> x >> y >> c;
        p[i] = { Vec(x, y), c };
    }

    if (k == 1) {
        cout << 0 << endl;
        exit(0);
    }

    double ans = 1e+100;

    auto g = [&](Vec v, double r) {
        int s = 0;
        for (int i = 0; i < n; i++) {
            double t = (v - p[i].v).norm() * p[i].c;
            if (t < r + eps) s++;
        }
        if (s >= k) ans = min(ans, r);
    };

    CL cl[2];
    auto f = [&](int i, int j, int h) {
        Vec v0 = (p[i].v * p[i].c + p[j].v * p[j].c) * (1.0 / (p[i].c + p[j].c));
        if (p[i].c == p[j].c) {
            Line l(v0, (p[i].v - p[j].v).rot90());
            cl[h].l = l;
            cl[h].i = 1;
        } else {
            Vec v1 = (p[i].v * p[i].c - p[j].v * p[j].c) * (1.0 / (p[i].c - p[j].c));
            Vec v2 = (v0 + v1) * 0.5;
            Circle c(v2, (v0 - v2).norm());
            cl[h].c = c;
            cl[h].i = 0;
        }
    };

    for (int i = 0; i < n; i++) {
        for (int j = 0; j < i; j++) {
            Vec v = (p[i].v * p[i].c + p[j].v * p[j].c) * (1.0 / (p[i].c + p[j].c));
            g(v, (p[i].v - v).norm() * p[i].c);

            f(i, j, 0);

            for (int k = 0; k < j; k++) {
                f(j, k, 1);

                Vec v[2];
                int m;
                if (cl[0].i == 0 && cl[1].i == 0) {
                    m = cl[0].c.intersect(cl[1].c, v);

                } else if (cl[0].i == 1 && cl[1].i == 1) {
                    m = cl[0].l.intersect(cl[1].l, v[0]);

                } else {
                    int h = cl[0].i != 0;
                    m = cl[h].c.intersect(cl[h ^ 1].l, v);
                }

                for (int h = 0; h < m; h++) {
                    g(v[h], (p[j].v - v[h]).norm() * p[j].c);
                }
            }
        }
    }

    printf("%.8f\n", ans);

    return 0;
}

Measured memory_bytes: 384