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 <cmath>
#include <random>
#include <iostream>
#include <iomanip>
#include <algorithm>

using namespace std;

const int maxn = 65;
const double pi = acos(-1.0);

double x[maxn], y[maxn], c[maxn];
int n, k;

double t[maxn];

inline double sqr(double x){
    return x * x;
}

inline double dist(double x1,double y1,double x2, double y2){
    return sqrt(sqr(x1 - x2) + sqr(y1 - y2));
}

double calc_time(double c_x,double c_y){
    for (int i = 1;i <= n;i++){
        t[i] = dist(c_x,c_y,x[i],y[i]) * c[i];
    }
    nth_element(t+1,t + k, t+n+1);
    return t[k];
}

int main(int argc, const char * argv[]) {
    cin >> n >> k;
    for (int i = 1;i <= n;i++){
        cin >> x[i] >> y[i] >> c[i];
    }
    random_device rd;
    mt19937 gen(rd());
    uniform_real_distribution<> dis2(-1000, 1000);
    double init_x = dis2(gen);
    double init_y = dis2(gen);

    double radius = 1500;
    double ans = calc_time(init_x,init_y);
    

    //hyperparemeters
    double alpha = 0.97;
    int rounds = 750;
    int randoms = 900;
    
  

    while (rounds--){
        double best_x = 0;
        double best_y = 0;
        double cur_best = 1e15;
        uniform_real_distribution<> dis(-radius, radius);
        for (int i = 1;i <= randoms;i++){
            double nx = init_x + dis(gen);
            double ny = init_y + dis(gen);
            double score = calc_time(nx, ny);
            if (score < cur_best){
                cur_best = score;
                best_x = nx;
                best_y = ny;
            }
        }
        if (cur_best < ans){
            init_x = best_x;
            init_y = best_y;
            ans = min(ans, cur_best);
        }

        radius *= alpha;
    }
    cout << fixed << setprecision(8);
    cout << ans << endl;
    return 0;
}