Not getting the required precision in a floating point based trivial problem.

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; 
  ll a[n]; 
  for(int i =0;i<n;i++) cin>>a[i];
  ll sum =0; 
  for(int i = k;i<n-k;i++) sum+=a[i]; 
  float ans = sum; 
  double din = (n-2*k);