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.15.1) (judge verdict: Accepted)

// This code is generated by [cargo-atcoder](https://github.com/tanakh/cargo-atcoder)
// Original source code:
/*
use proconio::input;

const EPS: f64 = 1e-9;

fn main() {
    input! {
        n: usize,
        k: usize,
        xycv: [(f64, f64, f64); n]
    };
    if k == 1 {
        println!("{}", 0);
        return;
    }

    let mut l = 0_f64;
    let mut r = 100_000_000_f64;
    for _ in 0..100 {
        let t = (l + r) / 2_f64;
        if is_ok(&xycv, k, t) {
            r = t;
        } else {
            l = t;
        }
    }

    println!("{:.10}", r);
}

fn is_ok(xycv: &Vec<(f64, f64, f64)>, k: usize, t: f64) -> bool {
    let cv: Vec<C> = xycv
        .iter()
        .map(|&(x, y, c)| C::new(V::new(x, y), t / c))
        .collect();

    let mut vv = Vec::new();
    for i in 0..cv.len() {
        for j in 0..i {
            let iv = cv[i].xp(&cv[j]);
            vv.extend(iv);
        }
    }
    for c in cv.iter() {
        vv.push(c.o);
    }

    for &v in vv.iter() {
        let mut count = 0;

        for &c in cv.iter() {
            if (v - c.o).norm() <= c.r + EPS {
                count += 1
            }
        }

        if count >= k {
            return true;
        }
    }
    false
}

#[derive(Clone, Copy)]
struct C {
    o: V,
    r: f64,
}

impl C {
    fn new(o: V, r: f64) -> Self {
        Self { o, r }
    }

    fn xp(&self, c: &C) -> Vec<V> {
        let v = c.o - self.o;
        let l = v.norm();
        if l < EPS {
            return vec![];
        }
        let x = (l * l - c.r * c.r + self.r * self.r) / (2.0 * l);
        let y = (self.r * self.r - x * x).sqrt();
        let m = self.o + v * (x / l);
        let rv = V::new(v.y, -v.x) * (y / l);
        vec![m + rv, m - rv]
    }
}

#[derive(Clone, Copy)]
struct V {
    x: f64,
    y: f64,
}

impl V {
    fn new(x: f64, y: f64) -> Self {
        Self { x, y }
    }

    fn norm(&self) -> f64 {
        (self.x * self.x + self.y * self.y).sqrt()
    }
}

impl std::ops::Add<V> for V {
    type Output = V;
    fn add(self, rhs: V) -> V {
        V {
            x: self.x + rhs.x,
            y: self.y + rhs.y,
        }
    }
}

impl std::ops::Sub<V> for V {
    type Output = V;
    fn sub(self, rhs: V) -> V {
        V {
            x: self.x - rhs.x,
            y: self.y - rhs.y,
        }
    }
}

impl std::ops::Mul<f64> for V {
    type Output = V;
    fn mul(self, rhs: f64) -> V {
        V {
            x: self.x * rhs,
            y: self.y * rhs,
        }
    }
}

impl std::ops::Div<f64> for V {
    type Output = V;
    fn div(self, rhs: f64) -> V {
        V {
            x: self.x / rhs,
            y: self.y / rhs,
        }
    }
}
*/

fn main() {
    let exe = "/tmp/bin348BDFC2";
    std::io::Write::write_all(&mut std::fs::File::create(exe).unwrap(), &decode(BIN)).unwrap();
    std::fs::set_permissions(exe, std::os::unix::fs::PermissionsExt::from_mode(0o755)).unwrap();
    std::process::exit(std::process::Command::new(exe).status().unwrap().code().unwrap())
}

fn decode(v: &str) -> Vec<u8> {
    let mut ret = vec![];
    let mut buf = 0;
    let mut tbl = vec![64; 256];
    for i in 0..64 { tbl[TBL[i] as usize] = i as u8; }
    for (i, c) in v.bytes().filter_map(|c| { let c = tbl[c as usize]; if c < 64 { Some(c) } else { None } }).enumerate() {
        match i % 4 {
            0 => buf = c << 2,
            1 => { ret.push(buf | c >> 4); buf = c << 4; }
            2 => { ret.push(buf | c >> 2); buf = c << 6; }
            3 => ret.push(buf | c),
            _ => unreachable!(),
        }
    }
    ret
}

const TBL: &'static [u8] = b"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
const BIN: &'static str = "<base64-encoded ELF executable removed>";