_takumi

yes

Aug 17th, 2021 (edited)
1,033
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.52 KB | None | 0 0
  1. #include <algorithm>
  2. #include <iostream>
  3. #include <iomanip>
  4. #include <numeric>
  5. #include <vector>
  6. using namespace std;
  7.  
  8. int main()
  9. {
  10.     int t = 0, n = 0, sum, cnt;
  11.     double temp = 0, ans, cmax;
  12.     cin >> t;
  13.     for (size_t i = 0; i < t; i++)
  14.     {
  15.         ans = 0;
  16.         cmax = INT_MIN;
  17.         cnt = 0;
  18.         sum = 0;
  19.         cin >> n;
  20.         for (size_t j = 0; j < n; j++)
  21.         {
  22.             cin >> temp;
  23.             sum += temp;
  24.             if (temp > cmax) cmax = temp;
  25.         }
  26.         ans = cmax + (double)((sum - cmax) / (n - 1));
  27.         cout << fixed << setprecision(9) << ans << endl;
  28.     }
  29. }
Advertisement
Add Comment
Please, Sign In to add comment