Language: C++

#include "bits/stdc++.h"
using namespace std;
typedef long long li;

typedef long double Real;
typedef complex<Real> Point;

Real cos(Real a, Real b, Real c) {
    return (b * b + c * c - a * a) / (2 * b * c);
}
Real acos2(Real a, Real b, Real c) {
    return acos(cos(a, b, c));
};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);

    li n, k;
    cin >> n >> k;

    vector<Point> meats;
    vector<Real> weights;
    for (int i = 0; i < n; ++i) {
        Real x, y, c;
        cin >> x >> y >> c;
        meats.emplace_back(x, y);
        weights.emplace_back(c);
    }

    auto count = [&](const Point center, const Real time) {
        li ret = 0;
        for (int i = 0; i < n; ++i) {
            if (abs(center - meats[i]) * weights[i] <= time) {
                ret += 1;
            }
        }
        return ret;
    };

    auto find_time = [&](const Point center) {
        Real p = 0, q = 1e9;
        for (int _it = 0; _it < 80; ++_it) {
            Real m = (p + q) / 2;
            if (count(center, m) < k) {
                p = m;
            } else {
                q = m;
            }
        }
        return (p + q) / 2;
    };

    Real ans = 1e300;
    // n = 1
    for (int i = 0; i < n; ++i) {
        ans = min(ans, find_time(meats[i]));
    }

    // n = 2
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < i; ++j) {
            Point center = (weights[i] * meats[i] + weights[j] * meats[j]) / (weights[i] + weights[j]);
            ans = min(ans, find_time(center));
        }
    }

    // n = 3
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < i; ++j) {
            for (int k = 0; k < j; ++k) {
                Point vdij = meats[j] - meats[i];
                Point vdik = meats[k] - meats[i];
                if (abs(vdij.real() * vdik.imag() - vdij.imag() * vdik.real()) < 1e-12) {
                    // colinear
                    continue;
                }

                Real p = 0, q = 1e9;
                Real dij = abs(meats[i] - meats[j]);
                Real djk = abs(meats[j] - meats[k]);
                Real dki = abs(meats[k] - meats[i]);

                for (int _it = 0; _it < 100; ++_it) {
                    Real m = (p + q) / 2;
                    Real di = m / weights[i];
                    Real dj = m / weights[j];
                    Real dk = m / weights[k];

                    bool exceed;
                    if (di + dj < dij) {
                        exceed = true;
                    } else if (dj + dk < djk) {
                        exceed = true;
                    } else if (dk + di < dki) {
                        exceed = true;
                    } else {
                        Real argij = acos2(dij, di, dj);
                        Real argjk = acos2(djk, dj, dk);
                        Real argki = acos2(dki, dk, di);

                        exceed = argij + argjk + argki > 2 * M_PI;
                    }
                    if (exceed) {
                        p = m;
                    } else {
                        q = m;
                    }

                }
                Real time = (p + q) / 2;
                Real di = time / weights[i];
                Real dj = time / weights[j];
                Point vij = (meats[j] - meats[i]) / dij;
                Real sgn = arg(vdik / vdij) > 0 ? 1 : -1;
                if (cos(dj, di, dij) > 1) {
                    continue;
                } else if (cos(dj, di, dij) < 0) {
                    continue;
                }
                Point vic = vij * polar(1., sgn * acos2(dj, di, dij));
                Point center = meats[i] + vic * di;

                ans = min(ans, find_time(center));
            }
        }
    }

    cout.precision(12);
    cout << fixed << ans << endl;
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:121:40: error: no matching function for call to 'polar(double, Real)'
  121 |                 Point vic = vij * polar(1., sgn * acos2(dj, di, dij));
      |                                   ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:127,
                 from a.cc:1:
/usr/include/c++/14/complex:967:5: note: candidate: 'template<class _Tp> std::complex<_Tp> std::polar(const _Tp&, const _Tp&)'
  967 |     polar(const _Tp& __rho, const _Tp& __theta)
      |     ^~~~~
/usr/include/c++/14/complex:967:5: note:   template argument deduction/substitution failed:
a.cc:121:40: note:   deduced conflicting types for parameter 'const _Tp' ('double' and 'Real' {aka 'long double'})
  121 |                 Point vic = vij * polar(1., sgn * acos2(dj, di, dij));
      |                                   ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~