I can’t imagine why this is failing over precision in floating point arithmetic, what is the reason and how to generally avoid such errors. The test case is too large to paste here, I took debug help.
Problem link
My output : -17659.273388
Expected : -17659.274296
void solve(){
int n,k;
cin>>n>>k;
ll a[n];
for(int i =0;i<n;i++) cin>>a[i];
sort(a,a+n);
ll sum =0;
for(int i = k;i<n-k;i++) sum+=a[i];
float ans = sum;
double din = (n-2*k);
cout<<std::fixed<<setprecision(6)<<((double(1.0*ans))/din)<<'\n';
}