比赛链接:https://codeforces.com/contest/1111
A不解释了
B 爆了int,调了半天,傻逼了...(#define int long long?逃...)
1 #include<iostream> 2 #include<cstdio> 3 #include<cstring> 4 #include<algorithm> 5 #include<cmath> 6 using namespace std; 7 const int maxn=1e5+5; 8 double hero[maxn],sum[maxn]; 9 int main() 10 { 11 //freopen("in.in","r",stdin); 12 long long n,m,k; 13 cin>>n>>k>>m; 14 for(int i=1;i<=n;i++) cin>>hero[i]; 15 sort(hero+1,hero+1+n);sum[0]=0; 16 for(int i=1;i<=n;i++) sum[i]=sum[i-1]+hero[i]; 17 double ans=0; 18 for(int i=0;i<min(n,m+1);i++) 19 { 20 int rem=n-i; 21 double sumt=sum[n]-sum[i]; 22 //cout<<sumt<<" "; 23 //cout<<sumt<<" "<<min(1.0*k*rem,1.0*m-i)<<" "; 24 sumt+=min(k*rem,m-i); 25 26 //cout<<sumt<<endl; 27 //printf("cmp:%d %d ",m*rem,m-i); 28 //cout<<sumt<<" "<<sumt/rem<<endl; 29 ans=max(sumt/rem,ans); 30 //printf("%f ",ans); 31 } 32 printf("%.10lf ",ans); 33 }