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;
#define rep(i, n)  for(long long i=0;i<(long long)(n);i++)
#define REP(i,k,n) for(long long i=k;i<(long long)(n);i++)
#define all(a) a.begin(),a.end()
#define pb push_back
#define eb emplace_back
#define lb(v,k) (lower_bound(all(v),k)-v.begin())
#define ub(v,k) (upper_bound(all(v),k)-v.begin())
#define fi first
#define se second
#define pi M_PI
typedef long long ll;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> PP;
typedef multiset<ll> S;
typedef priority_queue<ll> PQ;
typedef priority_queue<P,vector<P>,greater<P>> SPQ;
using vi=vector<ll>;
using vvi=vector<vi>;
using vvvi=vector<vvi>;
const ll inf=1001001001001001;
const int INF=1001001001;
const int mod=1000000007;
template<class T> bool chmin(T&a,T b){if(a>b){a=b;return true;}return false;}
template<class T> bool chmax(T&a,T b){if(a<b){a=b;return true;}return false;}
template<class T> void out(T a){cout<<a<<'\n';}
template<class T> void outp(T a){cout<<'('<<a.fi<<','<<a.se<<')'<<'\n';}
template<class T> void outvp(T v){rep(i,v.size())outp(v[i]);}
template<class T> void outv(T v){rep(i,v.size()){if(i)cout<<' ';cout<<v[i];}cout<<'\n';}
template<class T> void outvv(T v){rep(i,v.size()){rep(j,v[i].size()){if(j)cout<<' ';cout<<v[i][j];}cout<<'\n';}}
ll gcd(ll a,ll b){if(b==0)return a;return gcd(b,a%b);}
ll modpow(ll a,ll b){a%=mod;if(b==0)return 1;if(b&1)return a*modpow(a,b-1)%mod;ll k=modpow(a,b/2);return k*k%mod;}

int main(){

    ll n,k;cin>>n>>k;
// 配列xは円の中心のx座標, 配列yはy座標, 配列rは半径
    vector<double> x(n);
    vector<double> y(n);
    vector<double> r(n);



// 入力処理
    vector<double> t(n);
    rep(i,n)cin>>x[i]>>y[i]>>t[i];
    vvi v(2001,vi(2001));
    rep(i,n)v[x[i]+1000][y[i]+1000]++;
    ll ma=0;
    rep(i,2001)rep(j,2001)chmax(ma,v[i][j]);
    if(ma>=k){
        out(0);
        return 0;
    }
    double ok=3000000,ng=0;
    while(ok-ng>0.00000001){
        vector<double> xx,yy;
        double md=(ok+ng)/2;
        rep(i,n)r[i]=md/t[i];
        //outv(x);
        //outv(y);
        //outv(r);


// 円の組み合わせを全検索
    rep(c1,n){
        rep(c2,n){

// 二円の中心の距離を算出
            double dist_x = x[c1] - x[c2];
            dist_x*=dist_x; //自乗
            double dist_y = y[c1] - y[c2];
            dist_y*=dist_y;
            double dist = sqrt(dist_x+dist_y);

// 交わり判定
        if(!(dist <= (r[c1] + r[c2]) && dist >= fabs(r[c1]-r[c2])))continue;


// 交点の座標を調べるための準備
// 円Aの方程式 + 円Bの方程式 = 0を解いた時の
// ax + by + c = 0
        double a = (x[c2]-x[c1]);
        double b = (y[c2]-y[c1]);
        double c = (x[c1] * x[c1] + y[c1] * y[c1] - r[c1] * r[c1] - (x[c2] * x[c2] + y[c2] * y[c2] - r[c2] * r[c2]))/2;

//円と直線の交点については http://sora-blue.net/~shogo82148/memo/geometry/line-circle.html を参考に
//cout<< "a;" << a<<" b:" <<b <<" c:" <<c <<endl; //デバッグ用出力
        double d = a*x[c1]+b*y[c1]+c;
        double tmp=sqrt((a*a+b*b)*r[c1]*r[c1]-d*d);
        xx.pb((-a*d+b*tmp)/(a*a+b*b)+x[c1]);
        xx.pb((-a*d-b*tmp)/(a*a+b*b)+x[c1]);
        yy.pb((-b*d-a*tmp)/(a*a+b*b)+y[c1]);
        yy.pb((-b*d+a*tmp)/(a*a+b*b)+y[c1]);
/*ans[index].x[0]=(-a*d+b*tmp)/(a*a+b*b)+x[c1];
ans[index].x[1]=(-a*d-b*tmp)/(a*a+b*b)+x[c1];
ans[index].y[0]=(-b*d-a*tmp)/(a*a+b*b)+y[c1];
ans[index].y[1]=(-b*d+a*tmp)/(a*a+b*b)+y[c1];*/

// 交点の座標を出力
/*cout << "xans:" << ans[index].x[0] << endl;
cout << "yans:" << ans[index].y[0] << endl;
cout << "xans:" << ans[index].x[1] << endl;
cout << "yans:" << ans[index].y[1] << endl;
if(++index>=MAX) return -1; //解の格納エリアが満杯なので中止
} else {
cout << "円" << c1 << "と円" << c2 << "は交わっていない。" << endl;
}*/
        }
    }
    bool b=false;
    rep(i,xx.size()){
        ll num=0;
        double X=xx[i],Y=yy[i];
        rep(j,n){
            double dist_x = x[j] - X;
            dist_x*=dist_x; //自乗
            double dist_y = y[j] - Y;
            dist_y*=dist_y;
            double dist = sqrt(dist_x+dist_y);
            if(dist-0.00001<=r[j])num++;
        }
        //cout<<md<<' '<<num<<endl;
        if(num>=k){
            b=true;
            break;
     
        }
    }
    if(b)ok=md;
    else ng=md;
    }
    cout<<fixed<<setprecision(10);
    out(ok);
}