#include<iostream>
#include<algorithm>
#include<cmath>
using namespace std;
const int N = 5e5+10;
int n;
long double s;
int q[N];
int main(){
cin>>n>>s;
for(int i=0;i<n;i++) scanf("%d",&q[i]);
long double avg = s / n,res = 0;
sort(q,q+n);
for(int i=0;i<n;i++){
long double cur = s/(n-i);
if(cur>q[i]) cur = q[i];
res += (avg - cur) * (avg - cur);
s-=cur;
}
printf("%.4Lf",sqrt(res/n));
}
贪心算法求解付账问题(c++实现)
最新推荐文章于 2024-03-27 20:30:15 发布