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 Rust (1.42.0) (judge verdict: Accepted)

// ${url}
//
#![allow(unused_imports)]
use std::io::*;
use std::io::Write;
use std::fmt::*;
use std::str::*;
use std::cmp::*;
use std::collections::*;

// Input macros.
// Original by tanakh: https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };

    ($iter:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, [ next / $t:tt ]) => {
        {
            let len = read_value!($iter, usize);
            (0..len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
        }
    };

    ($iter:expr, switch) => {
        {
            let ty = read_value!($iter, i32);
            if ty == 1 {
                vec![ty, read_value!($iter, i32), read_value!($iter, i32)]
            } else if ty == 2 {
                vec![ty, read_value!($iter, i32)]
            } else {
                vec![ty, read_value!($iter, i32)]
            }
        }
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_macros)]
macro_rules! read_line {
    ($t:tt) => {
        {
            let mut s = String::new();
            std::io::stdin().read_line(&mut s).unwrap();
            s.trim_right().parse::<$t>().unwrap()
        }
    }
}

#[allow(unused_macros)]
macro_rules! dvec {
    ($t:expr ; $len:expr) => {
        vec![$t; $len]
    };

    ($t:expr ; $len:expr, $($rest:expr),*) => {
        vec![dvec!($t; $($rest),*); $len]
    };
}

#[allow(unused_macros)]
macro_rules! ifv {
    ($t:expr, $a:expr, $b: expr) => {
        if $t { $a } else { $b }
    }
}

#[allow(unused_macros)]
macro_rules! fill {
    ($t:expr, $v:expr) => {
        for i in 0..$t.len() {
            $t[i] = $v;
        }
    };
}

#[allow(unused_macros)]
macro_rules! join {
    ($t:expr, $glue:expr) => {
        $t.into_iter().map(|w| w.to_string()).collect::<Vec<_>>().join($glue)
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        eprintln!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

// ===

type Point = (f64, f64);
type Circle = (f64, f64, f64);


fn dist2(a: &Point, b: &Point) -> f64 {
    let u = a.0-b.0;
    let v = a.1-b.1;
    u*u+v*v
}


const INF: f64 = 1e10;
const EPS: f64 = 1e-9;

fn count(p: &Vec<Circle>, o: Point) -> usize {
    let mut ct = 0;
    for pi in p {
        if dist2(&(pi.0, pi.1), &o) <= pi.2*pi.2+EPS {
            ct += 1;
        }
    }
    ct
}

fn fmax(a: f64, b: f64) -> f64 {
    ifv!(a >= b, a, b)
}

fn rotate(p: &Point, r: f64) -> Point {
    (p.0 * r.cos() - p.1 * r.sin(), p.0 * r.sin() + p.1 * r.cos())
}

fn circle2(a: &Circle, b: &Circle) -> Option<(Point, Point)> {
    let d2 = dist2(&(a.0, a.1), &(b.0, b.1));
    if d2 <= 0.0 {
        return None;
    }
    let d = d2.sqrt();
    if d < (a.2-b.2).abs() {
        return None;
    }
    let r1cos = fmax(0.0, d*d + a.2*a.2 - b.2*b.2) / (2.0*d);
    let uh = (a.2*a.2 - r1cos*r1cos).sqrt();

    let ahe = ((b.0-a.0)/d,(b.1-a.1)/d);
    let up = rotate(&ahe, std::f64::consts::PI/2.0);
    let dw = rotate(&ahe, -std::f64::consts::PI/2.0);
    Some(((a.0+ahe.0*r1cos+up.0*uh, a.1+ahe.1*r1cos+up.1*uh),(a.0+ahe.0*r1cos+dw.0*uh, a.1+ahe.1*r1cos+dw.1*uh)))
}

fn main() {
    input! {
        n: usize, k: usize,
        mut p: [(f64, f64, f64); n]
    };


    let mut ok = INF;
    let mut ng = 0.0;
    for _cur in 0..500 {
        let mut pt = vec![];
        let med = (ok+ng)/2.0;
        let circles = p.iter().cloned().map(|pp| (pp.0, pp.1, med/pp.2)).collect::<Vec<_>>();

        for i in 0..n {
            pt.push((p[i].0, p[i].1));
            for j in 0..n {

                // debug!(circle2(&circles[i], &circles[j]), circle2(&circles[j], &circles[i]));

                if let Some((a, b)) = circle2(&circles[i], &circles[j]) {
                    pt.push(a);
                    pt.push(b);
                }
            }
        }
        let mut includes_k = false;
        for p in pt {
            if count(&circles, p) >= k {
                includes_k = true;
            }
        }
        if includes_k {
            ok = med;
        } else {
            ng = med;
        }
    }
    println!("{:.9}", ok);
}