QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#823523#4355. Seesawmakrav0 0ms3944kbC++201.7kb2024-12-21 06:45:592024-12-21 06:46:00

Judging History

你现在查看的是最新测评结果

  • [2024-12-21 06:46:00]
  • 评测
  • 测评结果:0
  • 用时:0ms
  • 内存:3944kb
  • [2024-12-21 06:45:59]
  • 提交

answer

#include <bits/stdc++.h>
#include <cassert>

using namespace std;
using ld = long double;
using ll = long long;

#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x).size()
#define pb push_back
#define ff first
#define sc second
#define int ll

mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
template<typename T>
void shuf(vector<T>& a) {
    for (int i = 1; i < sz(a); i++) swap(a[i], a[rnd() % (i + 1)]);
}

void solve() {
    int n; cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; i++) cin >> a[i];
    vector<int> pref(n + 1, 0);
    for (int i = 1; i <= n; i++) pref[i] = pref[i - 1] + a[i - 1];
    auto calc_avg = [&](int l, int r) -> ld {
        return ld(pref[r + 1] - pref[l]) / ld(r - l + 1);
    };
    int curl1 = 0, curr1 = n - 1, curl2 = 0, curr2 = n - 1;
    ld min1 = 1e18, max1 = 0, min2 = 1e18, max2 = 0;
    for (int i = 0; i < n; i++) {
        min1 = min(min1, calc_avg(curl1, curr1));
        max1 = max(max1, calc_avg(curl1, curr1));
        min2 = min(min2, calc_avg(curl2, curr2));
        max2 = max(max2, calc_avg(curl2, curr2));
        if (i % 2 == 0) {
            curl1++;
            curr2--;
        } else {
            curr1--;
            curl2++;
        }
    }
    cout << min(max1 - min1, max2 - min2) << '\n';
}

signed main() {
    cout << fixed << setprecision(10);
    int tt = 1;
    #ifdef LOCAL
        freopen("in.txt", "r", stdin);
        freopen("out.txt", "w", stdout);
        cin >> tt;
    #else
        ios::sync_with_stdio(false);
        cin.tie(0); cout.tie(0);
    #endif

    while (tt--) {
        solve();
    }

    return 0;
}

詳細信息

Subtask #1:

score: 0
Wrong Answer

Test #1:

score: 1
Accepted
time: 0ms
memory: 3872kb

input:

2
925278587 966813970

output:

20767691.5000000000

result:

ok found '20767691.500000000', expected '20767691.500000000', error '0.000000000'

Test #2:

score: 0
Wrong Answer
time: 0ms
memory: 3944kb

input:

20
7902238 121690240 160345001 255257832 269315023 288280211 296247186 353929891 494812700 530994847 567379029 567478415 612943598 644028258 654380821 696407711 708542915 738196686 743020754 760907139

output:

90705182.4210526316

result:

wrong answer 1st numbers differ - expected: '52991294.1666667', found: '90705182.4210526', error = '0.7116997'

Subtask #2:

score: 0
Skipped

Dependency #1:

0%

Subtask #3:

score: 0
Skipped

Dependency #1:

0%

Subtask #4:

score: 0
Skipped

Dependency #1:

0%