Submission #700576

# Submission time Handle Problem Language Result Execution time Memory
700576 2023-02-19T07:33:08 Z m_fenais Seesaw (JOI22_seesaw) C++17
1 / 100
2000 ms 256 KB
#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 time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 4 ms 212 KB Output is correct
3 Correct 7 ms 256 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 4 ms 212 KB Output is correct
3 Correct 7 ms 256 KB Output is correct
4 Execution timed out 2067 ms 212 KB Time limit exceeded
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 4 ms 212 KB Output is correct
3 Correct 7 ms 256 KB Output is correct
4 Execution timed out 2067 ms 212 KB Time limit exceeded
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 4 ms 212 KB Output is correct
3 Correct 7 ms 256 KB Output is correct
4 Execution timed out 2067 ms 212 KB Time limit exceeded
5 Halted 0 ms 0 KB -