#include #include #include #include #include #include int main() { std::cin.tie(nullptr)->sync_with_stdio(false); int N, K; std::cin >> N >> K; std::vector X(N), Y(N); for (int i{} ; i < N ; i++) std::cin >> X[i] >> Y[i]; const long double INF{(long double)1e18}; std::vector dp(N, std::vector(1 << N, INF)); for (int i{} ; i < N ; i++) { dp[i][1 << i] = sqrtl(X[i] * X[i] + Y[i] * Y[i]); } for (int bit{} ; bit < (1 << N) ; bit++) { for (int s{} ; s < N ; s++) if (bit & (1 << s)) { for (int t{} ; t < N ; t++) if (!(bit & (1 << t))) { if (dp[s][bit] > 1e15) continue; int dx{X[s] - X[t]}, dy{Y[s] - Y[t]}; dp[t][bit | (1 << t)] = std::min(dp[t][bit | (1 << t)], dp[s][bit] + sqrtl(dx * dx + dy * dy)); } } } std::vector cost(1 << N, INF); cost[0] = 0; for (int bit{} ; bit < (1 << N) ; bit++) for (int i{} ; i < N ; i++) if (bit & (1 << i)) { if (dp[i][bit] > 1e15) continue; cost[bit] = std::min(cost[bit], dp[i][bit] + sqrtl(X[i] * X[i] + Y[i] * Y[i])); } std::vector ep(1 << N, INF); ep[0] = 0; int all{(1 << N) - 1}; for (int bit{} ; bit < (1 << N) ; bit++) { assert(ep[bit] < 1e15); int can{all ^ bit}; for (int mask{can} ; mask ; mask = (mask - 1) & can) { if ((int)std::popcount((unsigned)mask) <= K) { assert((bit & mask) == 0); ep[bit | mask] = std::min(ep[bit | mask], ep[bit] + cost[mask]); } } } std::cout << std::fixed << std::setprecision(8) << ep[all] << '\n'; }