fork download
  1. #include <bits/stdc++.h>
  2.  
  3. using namespace std;
  4.  
  5. int n;
  6. long long a[1000005];
  7.  
  8. int main() {
  9. ios_base::sync_with_stdio(0);
  10. cin.tie(0);cout.tie(0);
  11. cin >> n;
  12. long long tong = 0;
  13. for(int i = 1 ; i <= n ; i++){
  14. cin >> a[i];
  15. tong = tong + a[i];
  16. }
  17.  
  18. sort(a + 1 , a + 1 + n);
  19.  
  20. long double res = ((long double)a[1] + a[2]) / 2;
  21. for(int i = 3 ; i <= n ; i++)
  22. res = (res + a[i]) / 2.0;
  23.  
  24. cout << fixed << setprecision(5) << res * n - tong << endl;
  25. }
Success #stdin #stdout 0.01s 5276KB
stdin
Standard input is empty
stdout
0.00000