Submission #677638

#TimeUsernameProblemLanguageResultExecution timeMemory
677638jhwest2Seesaw (JOI22_seesaw)C++17
100 / 100
98 ms11648 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef long double ld; const int N = 202020; int n; ll a[N], psum[N]; int main() { cin.tie(0); ios_base::sync_with_stdio(0); cin >> n; for (int i = 1; i <= n; i++) { cin >> a[i]; psum[i] = psum[i - 1] + a[i]; } vector<pair<ld, ld>> v(n); for (int i = 1; i <= n; i++) { int L = 0, R = i - 1; while (L < R) { int M = (L + R + 1) / 2; if ((ld)(psum[M + n + 1 - i] - psum[M]) / (n + 1 - i) <= (ld)psum[n] / n) L = M; else R = M - 1; } v[i - 1].first = (ld)(psum[L + n + 1 - i] - psum[L]) / (n + 1 - i); L = 0; R = i - 1; while (L < R) { int M = (L + R) / 2; if ((ld)(psum[M + n + 1 - i] - psum[M]) / (n + 1 - i) >= (ld)psum[n] / n) R = M; else L = M + 1; } v[i - 1].second = (ld)(psum[L + n + 1 - i] - psum[L]) / (n + 1 - i); } sort(v.begin(), v.end()); ld maxv = (ld)psum[n] / n; ld ans = 1e12; for (auto [x, y] : v) { ans = min(ans, maxv - x); maxv = max(maxv, y); } cout.precision(15); cout << fixed << ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...