import Control.Monad

type Point = (Double, Double)

main = do
  [n, k] <- map read.words <$> getLine
  meat <- replicateM n
    $ (\[x,y,c]->((x,y),c)).map read.words <$> getLine
  print $ solve k meat

solve :: Int -> [(Point, Double)] -> Double
solve k meat = bis 0 150000 where
  bis ng ok
    | ok - ng < 1e-9 = ok
    | cnt >= k = bis ng time
    | otherwise = bis time ok
    where
      time = (ng + ok) / 2
      cnt = maximum $ map count can
      count pos = length $ filter eval meat where
        eval (p, c) = dist p pos <= (time / c + 1e-9)
      can = mpos ++ concat [
        ccIntersect (p1, r1) (p2, r2)
        | (p1, c1) <- meat, let r1 = time / c1
        , (p2, c2) <- meat, let r2 = time / c2 ]
  mpos = map fst meat

dist p q = sqrt $ distSqr p q
distSqr (x1, y1) (x2, y2) = (x1 - x2) ^ 2 + (y1 - y2) ^ 2

ccIntersect :: (Point, Double) -> (Point, Double) -> [Point]
ccIntersect (p1, r1) (p2, r2)
  | d > 0 = [
      (a * x + y * sqrt d, a * y - x * sqrt d) /# sqs +# p1,
      (a * x - y * sqrt d, a * y + x * sqrt d) /# sqs +# p1
    ]
  | d == 0 = [a *# p /# sqs +# p1]
  | otherwise = []
  where
    p@(x, y) = p2 -# p1
    a = (sqs + r1 * r1 - r2 * r2) / 2
    sqs = distSqr p1 p2
    d = sqs * r1 * r1 - a * a

(a, b) +# (c, d) = (a + c, b + d)
(a, b) -# (c, d) = (a - c, b - d)
a *# (b, c) = (a * c, b * c)
(a, b) /# c = (a / c, b / c)