#include "bits/stdc++.h"
using namespace std;
typedef long long li;

typedef double Real;
typedef complex<Real> Point;

Real cos(Real a, Real b, Real c) {
    return (b * b + c * c - a * a) / (2 * b * c);
}
Real acos2(Real a, Real b, Real c) {
    return acos(cos(a, b, c));
};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);

    li n, k;
    cin >> n >> k;

    vector<Point> meats;
    vector<Real> weights;
    for (int i = 0; i < n; ++i) {
        Real x, y, c;
        cin >> x >> y >> c;
        meats.emplace_back(x, y);
        weights.emplace_back(c);
    }

    auto count = [&](const Point center, const Real time) {
        li ret = 0;
        for (int i = 0; i < n; ++i) {
            if (abs(center - meats[i]) * weights[i] <= time) {
                ret += 1;
            }
        }
        return ret;
    };

    auto find_time = [&](const Point center) {
        Real p = 0, q = 1e9;
        for (int _it = 0; _it < 80; ++_it) {
            Real m = (p + q) / 2;
            if (count(center, m) < k) {
                p = m;
            } else {
                q = m;
            }
        }
        return (p + q) / 2;
    };

    Real ans = 1e300;
    // n = 1
    for (int i = 0; i < n; ++i) {
        ans = min(ans, find_time(meats[i]));
    }

    // n = 2
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < i; ++j) {
            Point center = (weights[i] * meats[i] + weights[j] * meats[j]) / (weights[i] + weights[j]);
            ans = min(ans, find_time(center));
        }
    }

    // n = 3
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < i; ++j) {
            for (int k = 0; k < j; ++k) {
                Point vdij = meats[j] - meats[i];
                Point vdik = meats[k] - meats[i];
                if (abs(vdij.real() * vdik.imag() - vdij.imag() * vdik.real()) < 1e-9) {
                    // colinear
                    continue;
                }

                Real p = 0, q = 1e9;
                Real dij = abs(meats[i] - meats[j]);
                Real djk = abs(meats[j] - meats[k]);
                Real dki = abs(meats[k] - meats[i]);

                for (int _it = 0; _it < 100; ++_it) {
                    Real m = (p + q) / 2;
                    Real di = m / weights[i];
                    Real dj = m / weights[j];
                    Real dk = m / weights[k];

                    bool exceed;
                    if (di + dj < dij) {
                        exceed = true;
                    } else if (dj + dk < djk) {
                        exceed = true;
                    } else if (dk + di < dki) {
                        exceed = true;
                    } else {
                        Real argij = acos2(dij, di, dj);
                        Real argjk = acos2(djk, dj, dk);
                        Real argki = acos2(dki, dk, di);

                        exceed = argij + argjk + argki > 2 * M_PI;
                    }
                    if (exceed) {
                        p = m;
                    } else {
                        q = m;
                    }

                }
                Real time = (p + q) / 2;
                Real di = time / weights[i];
                Real dj = time / weights[j];
                Point vij = (meats[j] - meats[i]) / dij;
                Real sgn = arg(vdik / vdij) > 0 ? 1 : -1;
                if (cos(dj, di, dij) > 1) {
                    continue;
                } else if (cos(dj, di, dij) < -1) {
                    continue;
                }
                Point vic = vij * polar(1., sgn * acos2(dj, di, dij));
                Point center = meats[i] + vic * di;

                ans = min(ans, find_time(center));
            }
        }
    }

    cout.precision(12);
    cout << fixed << ans << endl;
    return 0;
}


Measured memory_bytes: 384