Submission #855611

#TimeUsernameProblemLanguageResultExecution timeMemory
855611MisterReaperSeesaw (JOI22_seesaw)C++17
0 / 100
1 ms348 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; #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 <int> pref = vec; for(int i = 1; i <= n; i++) pref[i] += pref[i -1]; 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)); }; i64 top = accumulate(vec.begin(), vec.end(), 0LL); cout << setprecision(15) << f(1, n, top * double(1) / n, top * 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...