用了方差公式变形
#include<bits/stdc++.h>
#define rep(i, a, b) for(int i = (a); i <= (b); i ++)
#define sqr(x) ((x)*(x))
using namespace std;
const int M = 5e5 + 5;
long double a[M];
signed main(){
int n;
long double S;
cin >> n >> S;
rep(i, 1, n) cin >> a[i];
sort(a + 1, a + 1 + n);
long double res = 0, sum = 0;
rep(i, 1, n){
int t = sum + (n - i + 1) * a[i];
if(t > S){
long double tmp = (S - sum) / (n - i + 1);
res += sqr(tmp) * (n - i + 1);
break;
}
sum += a[i];
res += sqr(a[i]);
}
long double ans = res / n - sqr(S / n);
if(abs(ans) < 1e-10) ans = 0;
else ans = sqrt(ans);
printf("%.4Lf", ans);
return 0;
}