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: Wrong Answer)

#![allow(unused)]

use kyoproio::*;
use std::{
    collections::*,
    io::{self, prelude::*},
    iter,
    mem::{replace, swap},
};

fn main() -> io::Result<()> {
    std::thread::Builder::new()
        .stack_size(50 * 1024 * 1024)
        .spawn(solve)?
        .join()
        .unwrap();
    Ok(())
}

fn solve() {
    let stdin = io::stdin();
    let mut kin = KInput::new(stdin.lock());
    let stdout = io::stdout();
    let mut out = io::BufWriter::new(stdout.lock());
    macro_rules! output {
        ($($args:expr),+) => { write!(&mut out, $($args),+) };
    }
    macro_rules! outputln {
        ($($args:expr),+) => { output!($($args),+); outputln!(); };
        () => { output!("\n"); if cfg!(debug_assertions) { out.flush(); } }
    }

    let (n, k): (usize, usize) = kin.input();
    let a: Vec<(f64, f64, f64)> = kin.seq(n);
    let ans = bisect(0., 1e7, 1e-7, |t| {
        let mut ps = Vec::new();
        for p1 in &a {
            ps.push((p1.0, p1.1));
            for p2 in &a {
                if std::ptr::eq(p1, p2) {
                    continue;
                }
                let (x1, y1, c1) = *p1;
                let (x2, y2, c2) = *p2;
                let r1 = t / c1;
                let r2 = t / c2;
                let sx = x2 - x1;
                let sy = y2 - y1;
                let h = sx * sx + sy * sy;
                /*
                if (r1 + r2) * (r1 + r2) < h {
                    continue;
                }
                */
                let a = (h + r1 * r1 - r2 * r2) / 2.;
                let v = (r1 * r1 / h - a / h * a / h).sqrt();
                if v.is_nan() {
                    continue;
                }
                let xu = (a * sx) / h;
                let yu = (a * sy) / h;
                let xv = sy * v;
                let yv = sx * v;
                ps.push((xu + xv + x1, yu - yv + y1));
                ps.push((xu - xv + x1, yu + yv + y1));
            }
        }
        for (x0, y0) in ps {
            let mut cnt = 0;
            for &(x1, y1, c) in &a {
                let r = t / c;
                if (x1 - x0).hypot(y1 - y0) <= r {
                    cnt += 1;
                }
            }
            if cnt >= k {
                return true;
            }
        }
        false
    });
    outputln!("{}", ans);
}

fn bisect(mut l: f64, mut r: f64, eps: f64, f: impl Fn(f64) -> bool) -> f64 {
    while r - l > 2. * eps {
        let x = l + (r - l) / 2.;
        if f(x) {
            r = x;
        } else {
            l = x;
        }
    }
    l + (r - l) / 2.
}


// -----------------------------------------------------------------------------
pub mod kyoproio {
    #![warn(unused)]
    use std::io::prelude::*;
    pub trait Input: Sized {
        fn str(&mut self) -> &str;
        fn bytes(&mut self) -> &[u8] {
            self.str().as_ref()
        }
        fn input<T: InputParse>(&mut self) -> T {
            self.input_fallible().expect("input error")
        }
        fn input_fallible<T: InputParse>(&mut self) -> Result<T, T::Err> {
            T::input(self)
        }
        fn iter<T: InputParse>(&mut self) -> Iter<T, Self> {
            Iter {
                input: self,
                _t: std::marker::PhantomData,
            }
        }
        fn seq<T: InputParse, B: std::iter::FromIterator<T>>(&mut self, n: usize) -> B {
            self.iter().take(n).collect()
        }
    }
    pub struct KInput<R> {
        src: R,
        buf: String,
        pos: usize,
    }
    impl<R: BufRead> KInput<R> {
        pub fn new(src: R) -> Self {
            Self {
                src,
                buf: String::with_capacity(1024),
                pos: 0,
            }
        }
    }
    impl<R: BufRead> Input for KInput<R> {
        fn str(&mut self) -> &str {
            loop {
                if self.pos >= self.buf.len() {
                    self.pos = 0;
                    self.buf.clear();
                    if self.src.read_line(&mut self.buf).expect("io error") == 0 {
                        return &self.buf;
                    }
                }
                let range = self.pos
                    ..self.buf[self.pos..]
                        .find(|c: char| c.is_ascii_whitespace())
                        .map(|i| i + self.pos)
                        .unwrap_or_else(|| self.buf.len());
                self.pos = range.end + 1;
                if range.end > range.start {
                    return &self.buf[range];
                }
            }
        }
    }
    pub struct Iter<'a, T, I> {
        input: &'a mut I,
        _t: std::marker::PhantomData<*const T>,
    }
    impl<'a, T: InputParse, I: Input> Iterator for Iter<'a, T, I> {
        type Item = T;
        fn next(&mut self) -> Option<Self::Item> {
            Some(self.input.input())
        }
    }
    pub trait InputParse: Sized {
        type Err: std::fmt::Debug;
        fn input<I: Input>(input: &mut I) -> Result<Self, Self::Err>;
    }
    macro_rules! from_str_impls {
        { $($T:ty)* } => {
            $(impl InputParse for $T {
                type Err = <$T as std::str::FromStr>::Err;
                fn input<I: Input>(input: &mut I) -> Result<Self, Self::Err> {
                    input.str().parse::<$T>()
                }
            })*
        };
    }
    from_str_impls! {
        String char bool f32 f64 isize i8 i16 i32 i64 i128 usize u8 u16 u32 u64 u128
    }
    macro_rules! tuple_impls {
        ($H:ident $($T:ident)*) => {
            impl<$H: InputParse, $($T: InputParse),*> InputParse for ($H, $($T),*) {
                type Err = ();
                fn input<I: Input>(input: &mut I) -> Result<Self, Self::Err> {
                    // ?
                    Ok(($H::input(input).unwrap(), $($T::input(input).unwrap()),*))
                }
            }
            tuple_impls!($($T)*);
        };
        () => {};
    }
    tuple_impls!(A B C D E F G);
}