Submission #700576

#TimeUsernameProblemLanguageResultExecution timeMemory
700576m_fenaisSeesaw (JOI22_seesaw)C++17
1 / 100
2067 ms256 KiB
#include <bits/stdc++.h> #define endl '\n' #define FAST ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0) #define int ll #define all(vec) vec.begin(), vec.end() typedef long long ll; using namespace std; const int N = 200 + 10, mod = 1e9 + 7; int n; double a[N], pref[N]; double solve(int l, int r, double cur, double mi, double mx) { if(l == r) { mi = min(cur, mi); mx = max(cur, mx); return abs(mx - mi); } double c1 = 0, c2 = 0; if(l < n) c1 = solve(l + 1, r, double(double(pref[r] - pref[l])/double(r-l)), min(mi, cur), max(mx, cur)); if(r > 1) c2 = solve(l, r - 1, double(double(pref[r-1] - pref[l-1])/double(r-l)), min(mi, cur), max(mx, cur)); return min(c1, c2); } signed main() { FAST; cin >> n; for(int i = 1; i <= n; i++) cin >> a[i]; pref[1] = a[1]; for(int i = 2; i <= n; i++) pref[i] += a[i] + pref[i-1]; cout << fixed << setprecision(9) << solve(1, n, double(pref[n]/n), double(pref[n]/n), double(pref[n]/n)) << endl; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...