#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <bitset>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <numeric>
#include <iostream>
#include <iomanip>
#include <string>
#include <chrono>
#include <random>
#include <cmath>
#include <cassert>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <functional>
#include <sstream>

using namespace std;

class Solution {
public:
    double solve(vector<pair<double,double>>& P, vector<int>& C, int K) {
        int n = P.size();

        double eps = 1e-10;

        auto distance = [&](pair<double, double>& A, pair<double,double>& B) {
            return hypot(A.first - B.first, A.second - B.second);
        };

        
        auto calc = [&](pair<double,double>& A, double Ra, pair<double, double>& B, double Rb) {
            vector<pair<double, double>> res;
            auto xa = A.first, ya = A.second;
            auto xb = B.first, yb = B.second;
            double c = Ra * Ra - Rb * Rb - (xa * xa - xb * xb) - (ya * ya - yb * yb);
            double a = -2 * (xa - xb);
            double b = -2 * (ya - yb);
            if (b == 0) {
                double x = c / a;
                double d = Ra * Ra - pow(x - xa, 2);
                if (d + eps > 0) {
                    if (d < 0) {
                        d = 0;
                    }
                    d = sqrt(d);
                    double y1 = ya + d;
                    double y2 = ya - d;
                    res.emplace_back(x, y1);
                    res.emplace_back(x, y2);
                }
            } else {
                double yaa = -(ya - c / b);
                double aa = pow(a / b, 2) + 1;
                double bb = -2 * (xa + a / b * yaa);
                double cc = -(Ra * Ra - xa * xa - yaa * yaa);

                double dd = bb * bb - 4 * aa * cc;
                if (dd + eps > 0) {
                    if (dd < 0) {
                        dd = 0;
                    }
                    dd = sqrt(dd);
                    double x1 = (-bb + dd) / (2 * aa);
                    double x2 = (-bb - dd) / (2 * aa);
                    double y1 = (c - a * x1) / b;
                    double y2 = (c - a * x2) / b;
                    res.emplace_back(x1, y1);
                    res.emplace_back(x2, y2);
                }

            }
            return res;
        };

        vector<double> R(n, 0);
        auto ok = [&](double t) {
            for (int i = 0; i < n; ++i) {
                R[i] = t / C[i];
            }

            vector<pair<double,double>> cands;
            for (auto& p : P) {
                cands.emplace_back(p);
            }

            for (int i = 0; i < n; ++i) {
                for (int j = i + 1; j < n; ++j) {
                    auto S = calc(P[i], R[i], P[j], R[j]);
                    for (auto& p : S) {
                        cands.push_back(p);
                    }
                }
            }

            int res = 0;
            for (auto& p : cands) {
                int cnt = 0;
                for (int i = 0; i < n; ++i) {
                    if (distance(p, P[i]) <= R[i] + eps) {
                        ++cnt;
                    }
                }
                res = max(res, cnt);
            }
            return res >= K;
        };

        double l = 0, r = 1 << 28;

        int rnd = 200;
        while (rnd -- > 0) {
            auto m = (l + r) / 2;
            if (ok(m)) {
                r = m;
            } else {
                l = m;
            }
        } 
        return l;
    }
};

int main(int argc, char** argv) {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(12);

    int n, k;
    cin >> n >> k;
    vector<pair<double,double>> P(n);
    vector<int> C(n);
    for (int i = 0; i < n; ++i) {
        int x, y, c;
        cin >> x >> y >> c;
        P[i] = make_pair(x, y);
        C[i] = c;
    }
    Solution sol;
    cout << sol.solve(P, C, k) << "\n";
    return 0;
}

Measured memory_bytes: 512