Language: C++

#include<iostream>
#include<cmath>
#include<vector>
#include<algorithm>
#include<iomanip>

using namespace std;

namespace v2d {

	struct Vec2 {
		//2次元ベクトルのクラス

		double x, y;
		Vec2(double _x, double _y) {
			x = _x, y = _y;
		}
		Vec2() {
			x = 0, y = 0;
		}

		Vec2 operator+() const {
			return *this;
		}
		Vec2 operator-() const {
			return{ -x, -y };
		}
		Vec2 operator+ (const Vec2& b) const {
			return{ x + b.x, y + b.y };
		}
		Vec2 operator- (const Vec2& b) const {
			return{ x - b.x, y - b.y };
		}
		Vec2 operator* (const double b) const {
			return{ x * b, y * b };
		}
		Vec2 operator/ (const double b) const {
			return{ x / b, y / b };
		}
		Vec2 operator+= (const Vec2& b) {
			x += b.x, y += b.y;
			return *this;
		}
		Vec2 operator-= (const Vec2& b) {
			x -= b.x, y -= b.y;
			return *this;
		}
		Vec2 operator*= (const double b) {
			x *= b, y *= b;
			return *this;
		}
		Vec2 operator/= (const double b) {
			x /= b, y /= b;
			return *this;
		}
		bool operator== (const Vec2& b) {
			return b.x == x && b.y == y;
		}

		double lengthSquare() {
			return (x * x + y * y);
		}
		double length() {
			return std::sqrt(lengthSquare());
		}
		double dot(const Vec2& b) {
			return x * b.x + y * b.y;
		}
		double cross(const Vec2& b) {
			//Generally, cross product is vector, but in 2D, cross product is also scalar.
			return x * b.y - y * b.x;
		}
		double distanceFrom(const Vec2& b) {
			return std::sqrt((x - b.x) * (x - b.x) + (y - b.y) * (y - b.y));
		}
		Vec2 normalized() {
			return{ x / length(), y / length() };
		}
		bool isZero() {
			return x == 0.0 && y == 0.0;
		}

		Vec2 normalUnitVector() {
			return {-normalized().y, normalized().x};
		}
	};

	inline Vec2 operator*(double a, const Vec2& b) {
		return{ b.x * a, b.y * a };
	}

	template <class Char>
	inline std::basic_ostream<Char>& operator <<(std::basic_ostream<Char>& os, const Vec2& v)
	{
		return os << Char('(') << v.x << Char(',') << v.y << Char(')');
	}

	template <class Char>
	inline std::basic_istream<Char>& operator >> (std::basic_istream<Char>& is, Vec2& v)
	{
		return is >> v.x >> v.y;
	}

	const Vec2 error_val = { 114514.0, -1919810.0 };
	const double eps = 1e-10;

	//交点が存在しないのなら、make_pair(error_val, error_val);を返す
	pair<Vec2, Vec2> crossPointInCircle(Vec2 p1, double r1, Vec2 p2, double r2) {
		if (p1 == p2)return make_pair(error_val, error_val);
		//p1中心の円を原点として考えることで、コーディング量が減る。
		
		Vec2 fp = p2 - p1;
		double fC = (pow(r1, 2) - pow(r2, 2) + fp.lengthSquare()) / 2.0;
		Vec2 ret1, ret2;

		if (fp.y == 0) {
			//yをxの式で表す関係上、fp.yで割る必要があるので、fp.y==0ならば例外処理をする。
			ret1.x = fC / fp.x, ret2.x = fC / fp.x;
			ret1.y = sqrt(pow(r1, 2) - pow(ret1.x, 2) + eps);
			ret2.y = -sqrt(pow(r1, 2) - pow(ret1.x, 2) + eps);
			ret1 += p1, ret2 += p1;
			return make_pair(ret1, ret2);
		}else  {
			
			//これは、交点を持たないとき
			if (pow(fp.x * fC, 2) - fp.lengthSquare() * (pow(fC, 2) - pow(fp.y * r1, 2)) - eps < 0) {
				return make_pair(error_val, error_val);
			}

			ret1.x = (fp.x * fC + sqrt(pow(fp.x * fC, 2) - fp.lengthSquare() * (pow(fC, 2) - pow(fp.y * r1, 2))))
				/ fp.lengthSquare();
			ret2.x = (fp.x * fC - sqrt(pow(fp.x * fC, 2) - fp.lengthSquare() * (pow(fC, 2) - pow(fp.y * r1, 2))))
				/ fp.lengthSquare();
			ret1.y = (fC - fp.x * ret1.x) / fp.y;
			ret2.y = (fC - fp.x * ret2.x) / fp.y;
			ret1 += p1, ret2 += p1;
			return make_pair(ret1, ret2);
		}
		
	}

}

using namespace v2d;

int N, K;
vector<Vec2> pos;
vector<double> c;

bool f(long double t) {
	//t秒以下でK枚の肉を焼きあげることができるか？
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < N; j++) {
			if (i == j)continue;
			//円iと円jの交点を求める。

			//そもそも離れすぎて交点を持ってない。
			if (pos[i].distanceFrom(pos[j]) > eps + (1.0 / c[i] + 1.0 / c[j]) * t) continue;

			//2つの交点の座標。1点でしか交わらなくても、cpos1とcpos2が同じになるだけなので実装上まとめる。
			auto tmp = crossPointInCircle(pos[i], t / c[i], pos[j], t / c[j]);
			if (tmp == make_pair(error_val, error_val))continue;//交わってない

			int cnt = 0;
			for (int k = 0; k < N; k++) {
				if ((tmp.first.distanceFrom(pos[k]) - t / c[k]) + eps < 0)
					cnt++;
			}
			
			if (cnt >= K)return true;

			cnt = 0;
			for (int k = 0; k < N; k++) {
				if ((tmp.second.distanceFrom(pos[k]) - t / c[k]) - eps < 0)
					cnt++;
			}
			if (cnt >= K)return true;
		}
	}
	return false;
}

int main() {

	cin >> N >> K;
	pos.resize(N), c.resize(N);
	for (int i = 0; i < N; i++) {
		cin >> pos[i] >> c[i];
	}
	
	if (K == 1) {
		cout << 0 << endl;
		return 0;
	}

	long double ok = 114514.0, ng = 0.0;
	const long double eps = 1e-8;
	while (ok - ng > eps) {
		long double mid = (ok + ng) / 2.0;
		if (f(mid))ok = mid;
		else ng = mid;
	}
	cout << setprecision(10) << ok << endl;
	return 0;
}


Compiler output:
In file included from /usr/include/c++/14/bits/stl_algobase.h:64,
                 from /usr/include/c++/14/string:51,
                 from /usr/include/c++/14/bits/locale_classes.h:40,
                 from /usr/include/c++/14/bits/ios_base.h:41,
                 from /usr/include/c++/14/ios:44,
                 from /usr/include/c++/14/ostream:40,
                 from /usr/include/c++/14/iostream:41,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_pair.h: In instantiation of 'constexpr bool std::operator==(const pair<_T1, _T2>&, const pair<_T1, _T2>&) [with _T1 = v2d::Vec2; _T2 = v2d::Vec2]':
a.cc:162:45:   required from here
  162 |                         if (tmp == make_pair(error_val, error_val))continue;//交わってない
      |                                                                  ^
/usr/include/c++/14/bits/stl_pair.h:1034:24: error: no match for 'operator==' (operand types are 'const v2d::Vec2' and 'const v2d::Vec2')
 1034 |     { return __x.first == __y.first && __x.second == __y.second; }
      |              ~~~~~~~~~~^~~~~~~~~~~~
a.cc:56:22: note: candidate: 'bool v2d::Vec2::operator==(const v2d::Vec2&)' (near match)
   56 |                 bool operator== (const Vec2& b) {
      |                      ^~~~~~~~
a.cc:56:22: note:   passing 'const v2d::Vec2*' as 'this' argument discards qualifiers
In file included from /usr/include/c++/14/iosfwd:42,
                 from /usr/include/c++/14/ios:40:
/usr/include/c++/14/bits/postypes.h:192:5: note: candidate: 'template<class _StateT> bool std::operator==(const fpos<_StateT>&, const fpos<_StateT>&)'
  192 |     operator==(const fpos<_StateT>& __lhs, const fpos<_StateT>& __rhs)
      |     ^~~~~~~~
/usr/include/c++/14/bits/postypes.h:192:5: note:   template argument deduction/substitution failed:
/usr/include/c++/14/bits/stl_pair.h:1034:24: note:   'const v2d::Vec2' is not derived from 'const std::fpos<_StateT>'
 1034 |     { return __x.first == __y.first && __x.second == __y.second; }
      |              ~~~~~~~~~~^~~~~~~~~~~~
In file included from /usr/include/c++/14/string:43:
/usr/include/c++/14/bits/allocator.h:235:5: note: candidate: 'template<class _T1, class _T2> bool std::operator==(const allocator<_CharT>&, const allocator<_T2>&)'
  235 |     operator==(const allocator<_T1>&, const allocator<_T2>&)
      |     ^~~~~~~~
/usr/include/c++/14/bits/allocator.h:235:5: note:   template argument deduction/substitution failed:
/usr/include/c++/14/bits/stl_pair.h:1034:24: note:   'const v2d::Vec2' is not derived from 'const std::allocator<_CharT>'
 1034 |     { return __x.first == __y.first && __x.second == __y.second; }
      |              ~~~~~~~~~~^~~~~~~~~~~~
In file included from /usr/include/c++/14/string:48:
/usr/include/c++/14/bits/stl_iterator.h:441:5: note: candidate: 'template<class _Iterator> constexpr bool std::operator==(const reverse_iterator<_Iterator>&, const reverse_iterator<_Iterator>&)'
  441 |     operator==(const reverse_iterator<_Iterator>& __x,
      |     ^~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:441:5: note:   template argument deduction/substitution failed:
/usr/include/c++/14/bits/stl_pair.h:1034:24: note:   'const v2d::Vec2' is not derived from 'const std::reverse_iterator<_Iterator>'
 1034 |     { return __x.first == __y.first && __x.second == __y.second; }
      |              ~~~~~~~~~~^~~~~~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:486:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr bool std::operator==(const reverse_iterator<_Iterator>&, const reverse_iterator<_IteratorR>&)'
  486 |     operator==(const reverse_iterator<_IteratorL>& __x,
      |     ^~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:486:5: note:   template argument deduction/substitution failed:
/usr/include/c++/14/bits/stl_pair.h:1034:24: note:   'const v2d::Vec2' is not derived from 'const std::reverse_iterator<_Iterator>'
 1034 |     { return __x.first == __y.first && __x.second == __y.second; }
      |              ~~~~~~~~~~^~~~~~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:1667:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr bool std::operator==(const move_iterator<_IteratorL>&, const move_iterator<_IteratorR>&)'
 1667 |     operator==(const move_iterator<_IteratorL>& __x,
      |     ^~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:1667:5: note:   template argument deduction/substitution failed:
/usr/include/c++/14/bits/stl_pair.h:1034:24: note:   'const v2d::Vec2' is not derived from 'const std::move_iterator<_IteratorL>'
 1034 |     { return __x.first == __y.first && __x.second == __y.second; }
      |              ~~~~~~~~~~^~~~~~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:1737:5: note: candidate: 'template<class _Iterator> constexpr bool std::operator==(const move_iterator<_IteratorL>&, const move_iterator<_IteratorL>&)'
 1737 |     operator==(const move_iterator<_Iterator>& __x,
      |     ^~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:1737:5: note:   template argument deduction/substitution failed:
/usr/include/c++/14/bits/stl_pair.h:1034:24: note:   'const v2d::Vec2' is not derived from 'const std::move_iterator<_IteratorL>'
 1034 |     { return __x.first == __y.first && __x.second == __y.second; }
      |              ~~~~~~~~~~^~~~~~~~~~~~
/usr/include/c++/14/bits/stl_pair.h:1033:5: note: candidate: 'template<class _T1, class _T2> constexpr bool std::operator==(const pair<_T1, _T2>&, const pair<_T1, _T2>&)'
 1033 |     operator==(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y)
      |     ^~~~~~~~
/usr/include/c++/14/bits/stl_pair.h:1033:5: note:   template argument deduction/substitution failed:
/usr/include/c++/14/bits/stl_pair.h:1034:24: note:   'const v2d::Vec2' is not derived from 'const std::pair<_T1, _T2>'
 1034 |     { return __x.first == __y.first && __x.second == __y.second; }
      |              ~~~~~~~~~~^~~~~~~~~~~~
/usr/include/c++/14/bits/stl_pair.h:1034:51: error: no match for 'operator==' (operand types are 'const v2d::Vec2' and 'const v2d::Vec2')
 1034 |     { return __x.first == __y.first && __x.second == __y.second; }
      |                                        ~~~~~~~~~~~^~~~~~~~~~~~~
a.cc:56:22: note: candidate: 'bool v2d::Vec2::operator==(const v2d::Vec2&)' (near match)
   56 |                 bool operator== (const Vec2& b) {
      |                      ^~~~~~~~
a.cc:56:22: note:   passing 'const v2d::Vec2*' as 'this' argument discards qualifiers
/usr/include/c++/14/bits/postypes.h:192:5: note: candidate: 'template<class _StateT> bool std::operator==(const fpos<_StateT>&, const fpos<_StateT>&)'
  192 |     operator==(const fpos<_StateT>& __lhs, const fpos<_StateT>& __rhs)
      |     ^~~~~~~~
/usr/include/c++/14/bits/postypes.h:192:5: note:   template argument deduction/substitution failed:
/usr/include/c++/14/bits/stl_pair.h:1034:51: note:   'const v2d::Vec2' is not derived from 'const std::fpos<_StateT>'
 1034 |     { return __x.first == __y.first && __x.second == __y.second; }
      |                                        ~~~~~~~~~~~^~~~~~~~~~~~~
/usr/include/c++/14/bits/allocator.h:235:5: note: candidate: 'template<class _T1, class _T2> bool std::operator==(const allocator<_CharT>&, const allocator<_T2>&)'
  235 |     operator==(const allocator<_T1>&, const allocator<_T2>&)
      |     ^~~~~~~~
/usr/include/c++/14/bits/allocator.h:235:5: note:   template argument deduction/substitution failed:
/usr/include/c++/14/bits/stl_pair.h:1034:51: note:   'const v2d::Vec2' is not derived from 'const std::allocator<_CharT>'
 1034 |     { return __x.first == __y.first && __x.second == __y.second; }
      |                                        ~~~~~~~~~~~^~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:441:5: note: candidate: 'template<class _Iterator> constexpr bool std::operator==(const reverse_iterator<_Iterator>&, const reverse_iterator<_Iterator>&)'
  441 |     operator==(const reverse_iterator<_Iterator>& __x,
      |     ^~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:441:5: note:   template argument deduction/substitution failed:
/usr/include/c++/14/bits/stl_pair.h:1034:51: note:   'const v2d::Vec2' is not derived from 'const std::reverse_iterator<_Iterator>'
 1034 |     { return __x.first == __y.first && __x.second == __y.second; }
      |                                        ~~~~~~~~~~~^~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:486:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr bool std::operator==(const reverse_iterator<_Iterator>&, const reverse_iterator<_IteratorR>&)'
  486 |     operator==(const reverse_iterator<_IteratorL>& __x,
      |     ^~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:486:5: note:   template argument deduction/substitution failed:
/usr/include/c++/14/bits/stl_pair.h:1034:51: note:   'const v2d::Vec2' is not derived from 'const std::reverse_iterator<_Iterator>'
 1034 |     { return __x.first == __y.first && __x.second == __y.second; }
      |                                        ~~~~~~~~~~~^~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:1667:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr bool std::operator==(const move_iterator<_IteratorL>&, const move_iterator<_IteratorR>&)'
 1667 |     operator==(const move_iterator<_IteratorL>& __x,
      |     ^~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:1667:5: note:   template argument deduction/substitution failed:
/usr/include/c++/14/bits/stl_pair.h:1034:51: note:   'const v2d::Vec2' is not derived from 'const std::move_iterator<_IteratorL>'
 1034 |     { return __x.first == __y.first && __x.second == __y.second; }
      |                                        ~~~~~~~~~~~^~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:1737:5: note: candidate: 'template<class _Iterator> constexpr bool std::operator==(const move_iterator<_IteratorL>&, const move_iterator<_IteratorL>&)'
 1737 |     operator==(const move_iterator<_Iterator>& __x,
      |     ^~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:1737:5: note:   template argument deduction/substitution failed:
/usr/include/c++/14/bits/stl_pair.h:1034:51: note:   'const v2d::Vec2' is not derived from 'const std::move_iterator<_Iterator