https://codeforces.net/problemset/problem/1557/A
void solve(){ ll n;cin>>n; vll arr(n); FOR(i,0,n)cin>>arr[i]; double m=*max_element(all(arr)); double sum = accumulate(all(arr),0); sum=sum-m; double avg = sum/(n-1);
cout<<fixed<<setprecision(10)<<m+avg<<endl;
}
Make sure everything is double. It might be due to precission errors but the idea is correct
everything is double......
Not n, neither te array i mean EVERYTHING becases that is how it works unfortunately
wrong countertest, misread problem
accumulate returns an integer value by default and due to constraints sum will overflow try
0ll
instead of0
in accumulate function and you are good to go.Your code fails on
5 1000000000 1000000000 1000000000 1000000000 1000000000