Problem:
Score : 600 points

Problem Statement

Takahashi wants to grill N pieces of meat on a grilling net, which can be seen as a two-dimensional plane. The coordinates of the i-th piece of meat are \left(x_i, y_i\right), and its hardness is c_i.

Takahashi can use one heat source to grill the meat. If he puts the heat source at coordinates \left(X, Y\right), where X and Y are real numbers, the i-th piece of meat will be ready to eat in c_i \times \sqrt{\left(X - x_i\right)^2 + \left(Y-y_i\right)^2} seconds.

Takahashi wants to eat K pieces of meat. Find the time required to have K or more pieces of meat ready if he put the heat source to minimize this time.

Constraints

All values in input are integers.

1 \leq N \leq 60

1 \leq K \leq N

-1000 \leq x_i , y_i \leq 1000

\left(x_i, y_i\right) \neq \left(x_j, y_j\right) \left(i \neq j \right)

1 \leq c_i \leq 100

Input

Input is given from Standard Input in the following format:

N K
x_1 y_1 c_1
\vdots
x_N y_N c_N

Output

Print the answer.

It will be considered correct if its absolute or relative error from our answer is at most 10^{-6}.

Sample Input 1

4 3
-1 0 3
0 0 3
1 0 2
1 1 40

Sample Output 1

2.4

If we put the heat source at \left(-0.2, 0\right), the 1-st, 2-nd, and 3-rd pieces of meat will be ready to eat within 2.4 seconds. This is the optimal place to put the heat source.

Sample Input 2

10 5
-879 981 26
890 -406 81
512 859 97
362 -955 25
128 553 17
-885 763 2
449 310 57
-656 -204 11
-270 76 40
184 170 16

Sample Output 2

7411.2252

Solution in C++14 (GCC 5.4.1) (judge verdict: Wrong Answer)

#include <bits/stdc++.h>
using namespace std;
template <class T> inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T> inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return 1;
    }
    return 0;
}
typedef long long int ll;

#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define endl "\n"
const double EPS = 1e-7;
const int INF = 1 << 30;
const ll LLINF = 1LL << 60;
const double PI = acos(-1);
const int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

//-------------------------------------

using Point = complex<double>;

struct Circle {
    Point p;
    double r;
    Circle() = default;
    Circle(Point _p, double _r) : p(_p), r(_r) {}
};

inline bool equal(const double &a, const double &b) {
    return (fabs(b - a) < EPS);
}

vector<Point> crossPoint(const Circle &c1, const Circle &c2) {
    vector<Point> res;
    // 2つの中心の距離
    double d = abs(c1.p - c2.p);
    // 2円が交点を持たない場合
    if(d > c1.r + c2.r + EPS) {
        return res;
    }
    if(equal(d, 0)) {
        return res;
    }
    if(d < abs(c1.r - c2.r) - EPS) {
        return res;
    }
    // 2円が接する場合
    if(equal(d, c1.r + c2.r)) {
        double t = c1.r / (c1.r + c2.r);
        res.emplace_back(c1.p + (c2.p - c1.p) * t);
        return res;
    }
    if(equal(d, abs(c1.r - c2.r))) {
        if(c2.r < c1.r - EPS) {
            res.emplace_back(c1.p + (c2.p - c1.p) * (c1.r / d));
        } else {
            res.emplace_back(c2.p + (c1.p - c2.p) * (c2.r / d));
        }
        return res;
    }
    // 2円が重なる場合
    double rc1 = (c1.r * c1.r + d * d - c2.r * c2.r) / (2 * d);
    double rs1 = sqrt(c1.r * c1.r - rc1 * rc1);
    Point e12 = (c2.p - c1.p) / abs(c2.p - c1.p);
    res.emplace_back(c1.p + rc1 * e12 + rs1 * e12 * Point(0, 1));
    res.emplace_back(c1.p + rc1 * e12 + rs1 * e12 * Point(0, -1));
    return res;
}

// 点pが円cの内部(円周上も含む)に入っているかどうか
bool isInCircle(const Circle &c, const Point &p) {
    double d = abs(c.p - p);
    return (equal(d, c.r) || d < c.r - EPS);
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, k;
    cin >> n >> k;
    vector<Circle> circle(n);
    vector<double> c(n);
    for(int i = 0; i < n; i++) {
        double x, y;
        cin >> x >> y >> c[i];
        circle[i] = Circle(Point(x, y), 1.0);
    }

    vector<Point> p;

    auto check = [&](double X) {
        for(int i = 0; i < n; i++) {
            circle[i].r = X / c[i];
        }
        p.clear();
        for(int i = 0; i < n; i++) {
            p.emplace_back(circle[i].p);
        }
        for(int i = 0; i < n; i++) {
            for(int j = i + 1; j < n; j++) {
                auto res = crossPoint(circle[i], circle[j]);
                for(const auto &pp : res) {
                    p.emplace_back(pp);
                }
            }
        }
        int ans = 0;
        for(const auto &pp : p) {
            int cnt = 0;
            for(int i = 0; i < n; i++) {
                cnt += isInCircle(circle[i], pp);
            }
            chmax(ans, cnt);
        }
        return (ans >= k);
    };

    double ok = 100000.0, ng = -0.1;
    int cnt = 100;
    while(cnt--) {
        double mid = (ok + ng) / 2.0;
        (check(mid) ? ok : ng) = mid;
    }
    cout << fixed << setprecision(10);
    cout << ok << endl;
}