Submission #810402

#TimeUsernameProblemLanguageResultExecution timeMemory
810402caganyanmazSeesaw (JOI22_seesaw)C++17
0 / 100
1 ms212 KiB
#include <bits/stdc++.h> #define int int64_t using namespace std; constexpr static int INF = 3e14; constexpr static double EPSILON = 0.000000000001; constexpr static int MXSIZE = 200000; int a[MXSIZE]; int32_t main() { int n; cin >> n; for (int i = 0; i < n; i++) cin >> a[i]; int sum = 0; for (int i = 0; i < n; i++) sum += a[i]; int la = sum, lb = n, ra = sum, rb = n; int step = 0; for (int l=0,r=n;r>l;step^=1) { if (step&1) { sum -= a[l++]; if (ra * (r-l) < sum * rb) { ra = sum; rb = r-l; } } else { sum -= a[--r]; if (la * (r-l) > sum * lb) { la = sum; lb = r-l; } } } double right = static_cast<double>(ra) / rb; double left = static_cast<double>(la) / lb; cout << fixed; cout << setprecision(15); cout << (right - left + EPSILON) <<"\n"; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...