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++ (GCC 9.2.1) (judge verdict: Wrong Answer)

#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<queue>
#include<cmath>
#include<cstdio>
#include<tuple>
#include<bitset>
#include<map>

using namespace std;
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define ALL(x) x.begin(),x.end()
#define ll long long
using lint=long long;
typedef pair<int,int> P;
const int inf=1000000007;
const int MOD=1000000007;
class Meet{
    public:
    double x,y,c;
    void input(){
        cin>>x>>y>>c;
    }
};
void calc(Meet a,Meet b,vector<pair<double,double>>& res,double r){
    res.push_back({a.x,a.y});
    res.push_back({b.x,b.y});
    if(b.x==0){
        double y=1.0/(2.0*b.y)*(1.0/(a.c*a.c)-1.0/(b.c*b.c))*r*r+b.y/2.0;
        if(r*r/(a.c*a.c)-y*y<0)return;
        double x=sqrt(r*r/(a.c*a.c)-y*y);
        res.push_back({x,y});
        res.push_back({-x,y});
        return;
    }
    double A=(1.0/(a.c*a.c)-1.0/(b.c*b.c))*r*r+b.x*b.x+b.y*b.y;A/=2.0*b.x;
    double div=1.0+(b.y*b.y)/(b.x*b.x);
    double B=-2.0*A*b.y/(b.x*div);
    double C=(A*A-r*r/a.c/a.c)/div;
    if(B*B-4.0*C<0)return;
    if(B*B-4.0*C==0){
        double y=-B/2.0;
        double x=-b.y/b.x*y+A;
        res.push_back({x,y});
        return;
    }
    double y=(-B+sqrt(B*B-4.0*C))/2.0;
    double x=-b.y/b.x*y+A;
    res.push_back({x,y});
    y=(-B-sqrt(B*B-4.0*C))/2.0;
    x=-b.y/b.x*y+A;
    res.push_back({x,y});
}
bool judge(vector<Meet>& niku,double r,int k){
    int n=niku.size();
    bool res=false;
    for(int i=0;i<n;++i){
        for(int j=i+1;j<n;++j){
            pair<double,double> move={niku[i].x,niku[i].y};
            niku[i].x=0;niku[i].y=0;
            niku[j].x-=move.first;niku[j].y-=move.second;
            vector<pair<double,double>> pos;
            calc(niku[i],niku[j],pos,r);
            niku[i].x=move.first;niku[i].y=move.second;
            niku[j].x+=move.first;niku[j].y+=move.second;
            for(auto& val:pos){
                val.first+=move.first;val.second+=move.second;
                int cnt=0;
                rep(x,n){
                    if((val.first-niku[x].x)*(val.first-niku[x].x)+(val.second-niku[x].y)*(val.second-niku[x].y)<=r*r/(niku[x].c*niku[x].c)+0.00005){
                        ++cnt;
                    }
                }
                if(cnt>=k){
                    //printf("x,y=%lf,%lf\n",val.first,val.second);
                    //printf("move(x, y)=%lf, %lf\n",move.first,move.second);
                    //printf("(i, j)=(%d, %d)\n",i,j);
                    return true;
                }
            }
        }
    }
    return res;
}
signed main(){  
  int n,k;cin>>n>>k;
  vector<Meet> niku(n);
  rep(i,n)niku[i].input();
  double res=1e18;
  double down=0.0;double up=1e9;
  rep(h,200){
      double mid=(down+up)/2.0;
      if(judge(niku,mid,k)){
          up=mid;
      }
      else down=mid;
  }
  res=up;
  printf("%.12lf\n",res);
  return 0;
}