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# (Mono 4.6.2.0) (judge verdict: Wrong Answer)

using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using static System.Math;
using MethodImplAttribute = System.Runtime.CompilerServices.MethodImplAttribute;
using MethodImplOptions = System.Runtime.CompilerServices.MethodImplOptions;

public static class P
{
    const double EPS = 1e-9;
    static int k;
    static Niku[] nikus;
    public static void Main()
    {
        var nk = Console.ReadLine().Split().Select(int.Parse).ToArray();
        var n = nk[0];
        k = nk[1];
        nikus = new Niku[n];
        for (int i = 0; i < n; i++)
        {
            var xyc = Console.ReadLine().Split().Select(int.Parse).ToArray();
            nikus[i] = new Niku() { Point = new Vector(xyc[0], xyc[1]), C = xyc[2] };
        }
        IsValid(2.40);
        var valid = 10000.0;
        var invalid = 0.0;
        for (int iter = 0; iter < 100; iter++)
        {
            var mid = (valid + invalid) / 2;
            if (IsValid(mid)) valid = mid;
            else invalid = mid;
        }
        Console.WriteLine(valid);
    }
    static bool IsValid(double time)
    {
        for (int i = 0; i < nikus.Length; i++)
        {
            for (int j = 0; j < nikus.Length; j++)
            {
                if (i == j) continue;
                var c1 = nikus[i].Point;
                var c2 = nikus[j].Point;
                var r1 = time / nikus[i].C;
                var r2 = time / nikus[j].C;
                double d = (c1 - c2).SqrtLength;
                if (r1 + r2 < d) continue;
                double a = Acos((r1 * r1 + d * d - r2 * r2) / (2 * r1 * d));
                var t = (c2 - c1).Angle;
                var p1 = c1 + new Vector(r1, 0).RotateVector(t + a);
                var p2 = c1 + new Vector(r1, 0).RotateVector(t - a);

                int count = 0;
                foreach (var x in nikus)
                {
                    if ((x.Point - p1).SqrtLength <= (time / x.C) + EPS) count++;
                }
                if (k <= count) return true;

                count = 0;
                foreach (var x in nikus)
                {
                    if ((x.Point - p2).SqrtLength <= (time / x.C) + EPS) count++;
                }
                if (k <= count) return true;

            }
        }
        return false;
    }
}


struct Niku
{
    public Vector Point;
    public int C;
}

struct Vector
{
    public double x;
    public double y;
    public double this[int index]
    {
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        get { if (index == 0) return x; else return y; }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        set { if (index == 0) x = value; else y = value; }
    }
    public double Length => x * x + y * y;
    public double SqrtLength => Math.Sqrt(Length);
    public double Angle => Atan2(y, x);
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public Vector(double x, double y) { this.x = x; this.y = y; }
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public Vector RotateVector(double radian) => new Vector((double)(x * Math.Cos(radian) - y * Math.Sin(radian)), (double)(x * Math.Sin(radian) + y * Math.Cos(radian)));
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    static public double CrossProduct(Vector a, Vector b) => a.x * b.y - a.y * b.x;
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    static public double InnerProduct(Vector a, Vector b) => a.x * b.x + a.y * b.y;
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public static Vector operator +(Vector a, Vector b) => new Vector(a.x + b.x, a.y + b.y);
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public static Vector operator -(Vector a, Vector b) => new Vector(a.x - b.x, a.y - b.y);
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public static bool operator ==(Vector a, Vector b) => a.x == b.x && a.y == b.y;
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public static bool operator !=(Vector a, Vector b) => a.x != b.x || a.y != b.y;
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public override bool Equals(object obj) => this == (Vector)obj;
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public override int GetHashCode() => x.GetHashCode() * 1000000007 + y.GetHashCode();
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public override string ToString() => $"({x},{y})";
}