Submission #855616

#TimeUsernameProblemLanguageResultExecution timeMemory
855616MisterReaperSeesaw (JOI22_seesaw)C++17
34 / 100
2054 ms860 KiB
//Bismillahirrahmanirrahim... #pragma GCC optimize("O3,unroll-loops") #pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt") //author: Ahmet Alp Orakci #include <bits/stdc++.h> using namespace std; using i64 = long long; using d80 = long double; #define double d80 #define ONLINE_JUDGE void solve() { int n; cin >> n; vector <int> vec(n +1); for(int i = 1; i <= n; i++) cin >> vec[i]; vector <i64> pref(n +1); for(int i = 1; i <= n; i++) pref[i] = pref[i -1] + vec[i]; function <double(int, int, double, double)> f = [&](int l, int r, double mn, double mx) -> double { if(l == r) { return mx - mn; } double _l = double(1) * (pref[r] - pref[l]) / (r - l); if(_l <= mx) { return f(l +1, r, mn, mx); } double _r = double(1) * (pref[r -1] - pref[l -1]) / (r - l); if(mn <= _r) { return f(l, r -1, mn, mx); } return min(f(l +1, r, mn, _l), f(l, r -1, _r, mx)); }; cout << setprecision(15) << f(1, n, pref[n] * double(1) / n, pref[n] * double(1) / n); return; } signed main() { #ifndef ONLINE_JUDGE freopen(".in", "r", stdin); freopen(".out", "w", stdout); #endif ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); int t = 1; //cin >> t; for(int i = 1; i <= t; i++) { solve(); } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...