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

#[macro_use]
mod input_mcr {
    // ref: tanakh <https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8>
    // diff: using Parser
    #[macro_export(local_inner_macros)]
    macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut parser = Parser::from_str($s);
        input_inner!{parser, $($r)*}
    };
    (parser = $parser:ident, $($r:tt)*) => {
        input_inner!{$parser, $($r)*}
    };
    (new_stdin_parser = $parser:ident, $($r:tt)*) => {
        let stdin = std::io::stdin();
        let reader = std::io::BufReader::new(stdin.lock());
        let mut $parser = Parser::new(reader);
        input_inner!{$parser, $($r)*}
    };
    ($($r:tt)*) => {
        input!{new_stdin_parser = parser, $($r)*}
    };
}

    #[macro_export(local_inner_macros)]
    macro_rules! input_inner {
    ($parser:ident) => {};
    ($parser:ident, ) => {};
    ($parser:ident, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($parser, $t);
        input_inner!{$parser $($r)*}
    };
}

    #[macro_export(local_inner_macros)]
    macro_rules! read_value {
    ($parser:ident, ( $($t:tt),* )) => {
        ( $(read_value!($parser, $t)),* )
    };
    ($parser:ident, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($parser, $t)).collect::<Vec<_>>()
    };
    ($parser:ident, chars) => {
        read_value!($parser, String).chars().collect::<Vec<char>>()
    };
    ($parser:ident, char_) => {
        read_value!($parser, String).chars().collect::<Vec<char>>()[0]
    };
    ($parser:ident, usize1) => {
        read_value!($parser, usize) - 1
    };
    ($parser:ident, i64_) => {
        $parser.fast_i64()
    };
    ($parser:ident, usize_) => {
        $parser.fast_i64() as usize
    };
    ($parser:ident, usize1_) => {
        ($parser.fast_i64() - 1) as usize
    };
    ($parser:ident, $t:ty) => {
        $parser.next::<$t>().expect("Parse error")
    };
}

    use std::io;
    use std::io::BufRead;
    use std::str;

    // ref: tatsuya6502 <https://qiita.com/tatsuya6502/items/cd448486f7ef7b5b8c7e>
    // ref: wariuni <https://qiita.com/tatsuya6502/items/cd448486f7ef7b5b8c7e#comment-7040a5ae96305e884eb9>
    // diff: using std::io::BufRead::fill_buf()
    pub struct Parser<R> {
        pub reader: R,
        buf: Vec<u8>,
        pos: usize,
    }

    impl Parser<io::Empty> {
        pub fn from_str(s: &str) -> Parser<io::Empty> {
            Parser {
                reader: io::empty(),
                buf: s.as_bytes().to_vec(),
                pos: 0,
            }
        }
    }

    impl<R: BufRead> Parser<R> {
        pub fn new(reader: R) -> Parser<R> {
            Parser {
                reader: reader,
                buf: vec![],
                pos: 0,
            }
        }
        pub fn update_buf(&mut self) {
            self.buf.clear();
            self.pos = 0;
            loop {
                let (len, complete) = {
                    let buf2 = self.reader.fill_buf().unwrap();
                    self.buf.extend_from_slice(buf2);
                    let len = buf2.len();
                    (len, buf2[len - 1] <= 0x20)
                };
                self.reader.consume(len);
                if complete {
                    break;
                }
            }
        }
        pub fn next<T: str::FromStr>(&mut self) -> Result<T, T::Err> {
            loop {
                let mut begin = self.pos;
                while begin < self.buf.len() && (self.buf[begin] <= 0x20) {
                    begin += 1;
                }
                let mut end = begin;
                while end < self.buf.len() && (self.buf[end] > 0x20) {
                    end += 1;
                }
                if begin != self.buf.len() {
                    self.pos = end;
                    return unsafe { str::from_utf8_unchecked(&self.buf[begin..end]) }.parse::<T>();
                } else {
                    self.update_buf();
                }
            }
        }
        pub fn fast_i64(&mut self) -> i64 {
            loop {
                let mut begin = self.pos;
                while begin < self.buf.len() && (self.buf[begin] <= 0x20) {
                    begin += 1;
                }
                if begin == self.buf.len() {
                    self.update_buf();
                    continue;
                }
                let mut res = 0;
                let (is_positive, mut end) = match self.buf[begin] {
                    b'+' => (true, begin + 1),
                    b'-' => (false, begin + 1),
                    _ => (true, begin),
                };
                while end < self.buf.len() && (self.buf[end] > 0x20) {
                    res = res * 10 + (self.buf[end] as i64 - '0' as i64);
                    end += 1;
                }
                if begin != self.buf.len() {
                    self.pos = end;
                    return if is_positive { res } else { -res };
                } else {
                    self.update_buf();
                }
            }
        }
    }
}

use input_mcr::*;
use std::cmp::*;

fn f(xs: &Vec<(i64, i64, i64)>, mask: usize, x: f64, y: f64) -> f64 {
    let mut res = 0.0;
    for (i, &(xi, yi, c)) in xs.iter().enumerate() {
        if mask & (1 << i) != 0 {
            let dx = x - xi as f64;
            let dy = y - yi as f64;
            let t = c as f64 * (dx * dx + dy * dy).sqrt();
            if res < t {
                res = t;
            }
        }
    }
    res
}

fn g2(xs: &Vec<(i64, i64, i64)>, mask: usize) -> (f64, f64) {
    let mut x = 0.0;
    let mut y = 0.0;
    let mut tc = 0;
    for (i, &(xi, yi, c)) in xs.iter().enumerate() {
        if mask & (1 << i) != 0 {
            tc += c;
            x += xi as f64 * c as f64;
            y += yi as f64 * c as f64;
        }
    }
    x /= tc as f64;
    y /= tc as f64;
    (x, y)
}

fn main() {
    input! {
        n: usize,
        m: usize,
        xs: [(i64,i64,i64); n],
    }
    let mut res = 1e200;
    for i in 0..n {
        let (x1, y1, c1) = xs[i];
        for k in i..n {
            let (x2, y2, c2) = xs[k];
            let gx = (x1 * c1 + x2 * c2) as f64 / (c1 + c2) as f64;
            let gy = (y1 * c1 + y2 * c2) as f64 / (c1 + c2) as f64;
            let t = {
                let dx = gx - x1 as f64;
                let dy = gy - y1 as f64;
                c1 as f64 * (dx * dx + dy * dy).sqrt()
            };
            let mut count = 0;
            for &(x, y, c) in &xs {
                let tt = {
                    let dx = gx - x as f64;
                    let dy = gy - y as f64;
                    c as f64 * (dx * dx + dy * dy).sqrt()
                };
                if tt < t + 1e-7 {
                    count += 1;
                }
            }
            if count >= m {
                if res > t {
                    res = t;
                }
            }
        }
    }
    println!("{:.20}", res);
    /*
    let mut mask = (1 << m) - 1;
    let mut score = 1e200;
    for iter in 0..1000 {
        let i = iter % n;
        let k = iter / n % n;
        if mask & (1 << i) != 0 && mask & (1 << k) == 0 {
            let new_mask = (mask & !(1 << i)) | (1 << k);
            let (x,y) = g2(&xs, mask);
            let new_score = f(&xs, mask, x, y);
            if score > new_score {
                mask = new_mask;
                score = new_score;
            }
        }
    }
    // eprintln!("mask = {}", mask);
    println!("{:.20}", score);
    // eprintln!("(x,y) = {:?}", g2(&xs, 7));
    // eprintln!(" -> {}", {
        let (x,y) = g2(&xs, 7);
        f(&xs, mask, x, y)
    });
    */
    /*
    let mut res = 1e200;
    let mut x_lower = -2000.0;
    let mut x_upper = 2000.0;
    for _ in 0..100 {
        let x_1 = (x_lower * 2.0 + x_upper * 1.0) / 3.0;
        let x_2 = (x_lower * 1.0 + x_upper * 2.0) / 3.0;
        let g = |x: f64| {
            let mut y_lower = -2000.0;
            let mut y_upper = 2000.0;
            for _ in 0..100 {
                let y_1 = (y_lower * 2.0 + y_upper * 1.0) / 3.0;
                let y_2 = (y_lower * 1.0 + y_upper * 2.0) / 3.0;
                let y_1_t = f(&xs, m, x, y_1);
                let y_2_t = f(&xs, m, x, y_2);
                if y_1_t > y_2_t {
                    y_lower = y_1;
                }
                else {
                    y_upper = y_2;
                }
            }
            // eprintln!("y_lower = {}", y_lower);
            f(&xs, m, x, y_lower)
        };
        let x_1_t = g(x_1);
        let x_2_t = g(x_2);
        if x_1_t > x_2_t {
            x_lower = x_1;
        }
        else {
            x_upper = x_2;
        }
        res = x_1_t;
        // eprintln!("x_lower = {}", x_lower);
    }
    println!("{:.20}", res);
    //// eprintln!("hoge = {}", f(&xs, m, -0.2, 0.0));
    */
}