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.Generic;
using System.IO;
using System.Linq;
using static System.Math;
using System.Text;
using System.Threading;
using System.Globalization;
using System.Runtime.CompilerServices;
using Library;

namespace Program
{
    public static class ABC157F
    {
        static public int numberOfRandomCases = 0;
        static public void MakeTestCase(List<string> _input, List<string> _output, ref Func<string[], bool> _outputChecker)
        {
        }
        static public void Solve()
        {
            var N = NN;
            var K = NN;
            var xycList = Repeat(0, N).Select(_ => new { x = ND, y = ND, c = ND }).ToArray();
            var left = 0M;
            var right = 3000000M;
            var centers = xycList.Select(e => new LIB_Geo2D.Vec(e.x, e.y)).ToArray();
            while (right - left > LIB_Geo2D.EPS)
            {
                var mid = (right + left) / 2;
                var cnt = 0L;
                {
                    var points = new List<LIB_Geo2D.Vec>();
                    var curcles = xycList.Select(e => new LIB_Geo2D.Circle() { p = new LIB_Geo2D.Vec(e.x, e.y), r2 = (mid / e.c) * (mid / e.c) }).ToArray();
                    for (var i = 0; i < N; i++)
                    {
                        for (var j = i + 1; j < N; j++)
                        {
                            points.AddRange(LIB_Geo2D.Intersection(curcles[i], curcles[j]));
                        }
                    }
                    foreach (var item in points.Concat(centers))
                    {
                        var thisCnt = 0L;
                        foreach (var item2 in curcles)
                        {
                            if (LIB_Geo2D.Distance(item, item2) <= LIB_Geo2D.EPS) ++thisCnt;
                        }
                        cnt = Max(cnt, thisCnt);
                    }
                }
                if (cnt < K) left = mid;
                else right = mid;
            }
            Console.WriteLine(right);
        }
        static class Console_
        {
            static Queue<string> param = new Queue<string>();
            public static string NextString() { if (param.Count == 0) foreach (var item in Console.ReadLine().Split(' ')) param.Enqueue(item); return param.Dequeue(); }
        }
        class Printer : StreamWriter
        {
            public override IFormatProvider FormatProvider { get { return CultureInfo.InvariantCulture; } }
            public Printer(Stream stream) : base(stream, new UTF8Encoding(false, true)) { base.AutoFlush = false; }
            public Printer(Stream stream, Encoding encoding) : base(stream, encoding) { base.AutoFlush = false; }
        }
        static public void Main(string[] args) { if (args.Length == 0) { Console.SetOut(new Printer(Console.OpenStandardOutput())); } var t = new Thread(Solve, 134217728); t.Start(); t.Join(); Console.Out.Flush(); }
        static long NN => long.Parse(Console_.NextString());
        static decimal ND => decimal.Parse(Console_.NextString());
        static string NS => Console_.NextString();
        static long[] NNList(long N) => Repeat(0, N).Select(_ => NN).ToArray();
        static decimal[] NDList(long N) => Repeat(0, N).Select(_ => ND).ToArray();
        static string[] NSList(long N) => Repeat(0, N).Select(_ => NS).ToArray();
        static IEnumerable<T> OrderByRand<T>(this IEnumerable<T> x) => x.OrderBy(_ => xorshift);
        static long Count<T>(this IEnumerable<T> x, Func<T, bool> pred) => Enumerable.Count(x, pred);
        static IEnumerable<T> Repeat<T>(T v, long n) => Enumerable.Repeat<T>(v, (int)n);
        static IEnumerable<int> Range(long s, long c) => Enumerable.Range((int)s, (int)c);
        static IEnumerable<string> OrderBy(this IEnumerable<string> x) => x.OrderBy(e => e, StringComparer.OrdinalIgnoreCase);
        static IEnumerable<T> OrderBy<T>(this IEnumerable<T> x, Func<T, string> selector) => x.OrderBy(selector, StringComparer.OrdinalIgnoreCase);
        static IEnumerable<string> OrderByDescending(this IEnumerable<string> x) => x.OrderByDescending(e => e, StringComparer.OrdinalIgnoreCase);
        static IEnumerable<T> OrderByDescending<T>(this IEnumerable<T> x, Func<T, string> selector) => x.OrderByDescending(selector, StringComparer.OrdinalIgnoreCase);
        static uint xorshift { get { _xsi.MoveNext(); return _xsi.Current; } }
        static IEnumerator<uint> _xsi = _xsc();
        static IEnumerator<uint> _xsc() { uint x = 123456789, y = 362436069, z = 521288629, w = (uint)(DateTime.Now.Ticks & 0xffffffff); while (true) { var t = x ^ (x << 11); x = y; y = z; z = w; w = (w ^ (w >> 19)) ^ (t ^ (t >> 8)); yield return w; } }
    }
}
namespace Library
{
}
namespace Library {
    class LIB_Geo2D
    {
        static readonly public decimal EPS = 1e-6M;
        public struct Vec
        {
            public decimal x;
            public decimal y;
            public Vec(decimal x, decimal y) { this.x = x; this.y = y; }
            [MethodImpl(MethodImplOptions.AggressiveInlining)]
            static public Vec operator +(Vec a, Vec b) => new Vec() { x = a.x + b.x, y = a.y + b.y };
            [MethodImpl(MethodImplOptions.AggressiveInlining)]
            static public Vec operator -(Vec a, Vec b) => new Vec() { x = a.x - b.x, y = a.y - b.y };
            [MethodImpl(MethodImplOptions.AggressiveInlining)]
            static public Vec operator *(Vec p, decimal v) => new Vec() { x = p.x * v, y = p.y * v };
            [MethodImpl(MethodImplOptions.AggressiveInlining)]
            static public Vec operator *(decimal v, Vec p) => p * v;
            [MethodImpl(MethodImplOptions.AggressiveInlining)]
            static public Vec operator /(Vec p, decimal v) => new Vec() { x = p.x / v, y = p.y / v };
            [MethodImpl(MethodImplOptions.AggressiveInlining)]
            static public Vec operator /(decimal v, Vec p) => p / v;
        }
        public struct Circle
        {
            public Vec p;
            /// <summary>
            /// 蜊雁ｾ・・2荵・            /// </summary>
            public decimal r2;
            /// <summary>
            /// 蜊雁ｾ・            /// </summary>
            public decimal r
            {
                [MethodImpl(MethodImplOptions.AggressiveInlining)]
                get { return (decimal)Sqrt((double)r2); }
                private set { }
            }
        }
        /// <summary>
        /// 轤ｹ縺ｨ轤ｹ縺ｮ霍晞屬縺ｮ2荵励ｒ豎ゅａ繧・        /// </summary>
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        static public decimal Distance(Vec p1, Vec p2) => Norm(p2 - p1);
        /// <summary>
        /// 轤ｹ縺ｨ蜀・・霍晞屬縺ｮ2荵励ｒ豎ゅａ繧九りｲ縺ｮ蝣ｴ蜷医・蜀・・蜀・・縺ｫ縺・ｋ・育ｵｶ蟇ｾ蛟､縺ｯ荳逡ｪ霑代＞蜀・・邵√∪縺ｧ縺ｮ霍晞屬・・        /// </summary>
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        static public decimal Distance(Vec p, Circle c) => Norm(p - c.p) - c.r2;
        /// <summary>
        /// 轤ｹ縺ｨ蜀・・霍晞屬縺ｮ2荵励ｒ豎ゅａ繧九りｲ縺ｮ蝣ｴ蜷医・蜀・・蜀・・縺ｫ縺・ｋ・育ｵｶ蟇ｾ蛟､縺ｯ荳逡ｪ霑代＞蜀・・邵√∪縺ｧ縺ｮ霍晞屬・・        /// </summary>
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        static public decimal Distance(Circle c, Vec p) => Norm(p - c.p) - c.r2;
        /// <summary>
        /// 蜀・→蜀・・莠､轤ｹ繧呈ｱゅａ繧・        /// </summary>
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        static public Vec[] Intersection(Circle c1, Circle c2)
        {
            var p = c2.p - c1.p;
            var b = p.x * p.x + p.y * p.y;
            var a = (b + c1.r2 - c2.r2) / 2;
            var d = b * c1.r2 - a * a;
            if (d < -EPS) return new Vec[0];
            if (d > EPS)
            {
                var c = (decimal)Sqrt((double)d);
                var p1 = new Vec((a * p.x + p.y * c) / b + c1.p.x, (a * p.y - p.x * c) / b + c1.p.y);
                var p2 = new Vec((a * p.x - p.y * c) / b + c1.p.x, (a * p.y + p.x * c) / b + c1.p.y);
                return new[] { p1, p2 };
            }
            return new[] { new Vec(a * p.x / b + c1.p.x, a * p.y / b + c1.p.y) };
        }
        /// <summary>
        /// p縺ｮ髟ｷ縺輔・2荵励ｒ蠕励ｋ
        /// </summary>
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        static public decimal Norm(Vec p) => p.x * p.x + p.y * p.y;
        /// <summary>
        /// 蜀・ｩ・        /// </summary>
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        static public decimal Dot(Vec p1, Vec p2) => p1.x * p2.x + p1.y * p2.y;
        /// <summary>
        /// 螟也ｩ搾ｼ亥ｹｳ陦悟屁霎ｺ蠖｢縺ｮ髱｢遨搾ｼ芽ｲ縺ｫ縺ｪ繧雁ｾ励ｋ
        /// </summary>
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        static public decimal Cross(Vec p1, Vec p2) => p1.x * p2.y - p1.y * p2.x;
        /// <summary>
        /// 3轤ｹ繧帝壹ｋ蜀・ｒ霑斐☆
        /// </summary>
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        static public Circle GetCircleFrom3Vec(Vec p1, Vec p2, Vec p3)
        {
            var A = Distance(p2, p3);
            var B = Distance(p1, p3);
            var C = Distance(p1, p2);
            var S = Abs(Cross(p2 - p1, p3 - p1));
            var p = (A * (B + C - A) * p1 + B * (C + A - B) * p2 + C * (A + B - C) * p3) / (4 * S * S);
            var r = Distance(p, p1);
            return new Circle() { p = p, r2 = r };
        }
        /// <summary>
        /// 2轤ｹ繧帝壹ｋ蜀・ｒ霑斐☆
        /// </summary>
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        static public Circle GetCircleFrom2Vec(Vec p1, Vec p2)
        {
            var c = (p1 + p2) / 2;
            return new Circle() { p = c, r2 = Distance(p1, c) };
        }
        /// <summary>
        /// 譛蟆丞桁蜷ｫ蜀・ｒ霑斐☆
        /// </summary>
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        static public Circle GetEncloseCircle(IEnumerable<Vec> pointList)
        {
            var pList = pointList.ToArray();
            if (pList.Length < 2) throw new Exception();
            var rnd = new Random();
            var list = pList.OrderBy(_ => rnd.Next()).ToArray();
            Func<Vec, Circle, bool> inCircle = null;
            inCircle = (p, c) => Distance(p, c) < EPS;
            {
                var c = GetCircleFrom2Vec(list[0], list[1]);
                for (var i = 2; i < list.Length; i++)
                {
                    if (!inCircle(list[i], c))
                    {
                        c = GetCircleFrom2Vec(list[0], list[i]);
                        for (var j = 1; j < i; j++)
                        {
                            if (!inCircle(list[j], c))
                            {
                                c = GetCircleFrom2Vec(list[i], list[j]);
                                for (var k = 0; k < j; k++)
                                {
                                    if (!inCircle(list[k], c))
                                    {
                                        c = GetCircleFrom3Vec(list[i], list[j], list[k]);
                                    }
                                }
                            }
                        }
                    }
                }
                return c;
            }
        }
    }
}