제출 #1127008

#제출 시각아이디문제언어결과실행 시간메모리
1127008gawr_guraSeesaw (JOI22_seesaw)C++20
0 / 100
9 ms392 KiB
#include <bits/stdc++.h> using namespace std; const int N = 200'000 + 10; int n; int a[N]; namespace sub1 { bool checkCondition() { return n <= 20; } int pref[N]; long double answer; void recursion(int l, int r, long double mi, long double ma) { if (l == r) { answer = min(answer, ma - mi); return; } { // left long double nMid = (long double) (pref[r] - pref[l]) / (r - l); recursion(l + 1, r, min(mi, nMid), max(ma, nMid)); } { // right long double nMid = (long double) (pref[r - 1] - pref[l - 1]) / (r - l); recursion(l, r - 1, min(mi, nMid), max(ma, nMid)); } } void solve() { for (int i = 1; i <= n; ++i) pref[i] = pref[i - 1] + a[i]; long double mid = (long double) pref[n] / n; answer = 1e9; recursion(1, n, mid, mid); cout << setprecision(10) << fixed << answer << "\n"; } } int32_t main() { cin.tie(0)->sync_with_stdio(0); cin >> n; for (int i = 1; i <= n; ++i) cin >> a[i]; if (sub1::checkCondition()) { sub1::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...