답안 #855616

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
855616 2023-10-01T13:59:43 Z MisterReaper Seesaw (JOI22_seesaw) C++17
34 / 100
2000 ms 860 KB
//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;
using d80 = long double;
#define double d80

#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 <i64> pref(n +1);
    for(int i = 1; i <= n; i++)
        pref[i] = pref[i -1] + vec[i];

    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));
    };

    cout << setprecision(15) << f(1, n, pref[n] * double(1) / n, pref[n] * 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;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Execution timed out 2054 ms 860 KB Time limit exceeded
9 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Execution timed out 2054 ms 860 KB Time limit exceeded
9 Halted 0 ms 0 KB -