-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.cpp
More file actions
52 lines (45 loc) · 1.32 KB
/
test.cpp
File metadata and controls
52 lines (45 loc) · 1.32 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#include "bits/stdc++.h"
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
//#define LOCAL //Comment in if custom header not set //Comment out when submitting
#define endl '\n' //Comment out if interactive
#define int long long //Comment out if memory exceeds
using namespace std;
//const int MOD=1000000007; //Comment in if question asks to take mod by this number
void solve() {
//Write your solution here
int n;
cin>>n;
int a[n];
int max = INT_MIN;
double sum = 0;
for(int i = 0; i<n; i++) {
cin>>a[i];
sum += a[i];
if(a[i] > max) max = a[i];
}
sum -= max;
double ans = max + (sum)/(n-1);
printf("%.9f \n",ans);
}
signed main() {
ios::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
#ifndef LOCAL
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
auto start_timer = chrono::high_resolution_clock::now();
#endif
int t=1;
cin>>t; //Comment out if single test case
while (t--) {
solve();
}
#ifdef LOCAL
auto stop_timer = chrono::high_resolution_clock::now();
auto duration = chrono::duration_cast<chrono::nanoseconds>(stop_timer - start_timer);
cerr << "Time taken : " << ((long double)duration.count())/((long double) 1e9) <<"s "<< endl;
#endif
return 0;
}