#include #include #include #include #include #include // accumulate #include using namespace std; typedef long long ll; typedef long double ld; ld res; void check(ld x) { if (fabs(x) < res) res = fabs(x); } ld solve() { ll n, k, xbar; vector::iterator it; cin >> n >> k >> xbar; vector x(n); for (ll &xi : x) cin >> xi; for (ll &xi : x) xi -= xbar; // set xbar = 0 WLOG sort(x.begin(), x.end()); ll s = accumulate(x.begin(), x.end(), 0LL); res = (ld)fabs(s) / n; // do not remove anything if (k == 1) { for (int i = 0; i < n; i++) check((ld)(s - x[i]) / (n - 1)); } if (k == 2) { for (int i = 0; i < n; i++) for (int j = 0; j < i; j++) check((ld)(s - x[i] - x[j]) / (n - 2)); } if (k == 3) { multiset cantake; for (int i = 0; i < n; i++) { cantake.insert(x[i]); } for (int i = 0; i < n; i++) { // now we cannot remove something that uses index i (or before) cantake.erase(cantake.find(x[i])); for (int j = 0; j < i; j++) { ll goal = s - x[i] - x[j]; auto it = cantake.lower_bound(goal); if (it != cantake.end()) { check((ld)(goal - *it) / (n - 3)); } if (it != cantake.begin()) { check((ld)(goal - *--it) / (n - 3)); } } } } if (k == 4) { multiset cantake; for (int i = 0; i < n; i++) { for (int j = 0; j < i; j++) { cantake.insert(x[i] + x[j]); } } for (int i = 0; i < n; i++) { // now we cannot remove something that uses index i (or before) for (int j = i + 1; j < n; j++) cantake.erase(cantake.find(x[i] + x[j])); for (int j = 0; j < i; j++) { ll goal = s - x[i] - x[j]; auto it = cantake.lower_bound(goal); if (it != cantake.end()) { check((ld)(goal - *it) / (n - 4)); } if (it != cantake.begin()) { check((ld)(goal - *--it) / (n - 4)); } } } } assert(k <= 4); // k >= 5 not supported return res; } int main() { (cout << fixed).precision(9); cout << solve() << endl; }