QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#706765#8242. V-Diagramyumingsk#WA 78ms3988kbC++201.2kb2024-11-03 13:22:062024-11-03 13:22:07

Judging History

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

  • [2024-11-03 13:22:07]
  • 评测
  • 测评结果:WA
  • 用时:78ms
  • 内存:3988kb
  • [2024-11-03 13:22:06]
  • 提交

answer

#pragma GCC optimize(3, "Ofast", "inline")
#include <iostream>
#include <bits/stdc++.h>
#define IOS ios::sync_with_stdio(false), cin.tie(0), cout.tie(0)
#define INF 0x3f3f3f3f
#define L_INF 0x7f3f3f3f3f3f3f3f
#define db cout << "debug\n";

using namespace std;
const int Mod = 998244353;
using ll = long long;
ll n, s, a[300011], k, l, r;

void solve()
{
    cin >> n;
    s = 0;
    for (int i = 1; i <= n; i++)
    {
        cin >> a[i];
        s += a[i];
    }
    for (int i = 2; i < n; i++)
        if (a[i] < a[i - 1] && a[i] < a[i + 1])
            k = i;
    l = 1;
    r = n;
    while (l < k - 1 && a[l] * (r - l + 1) < s)
    {
        s -= a[l];
        l++;
    }
    while (r > k + 1 && a[r] * (r - l + 1) < s)
    {
        s -= a[r];
        r--;
    }
    cout << fixed << setprecision(16) << (double)(s) / (r - l + 1) << '\n';
}
int main()
{
    IOS;
// freopen("in.txt", "r", stdin);
// freopen("out.txt", "w", stdout);
#ifndef ONLINE_JUDGE
    clock_t start_time = clock();
#endif
    int t = 1;
    cin >> t;
    while (t--)
    {
        solve();
    }
#ifndef ONLINE_JUDGE
    cout << "Used " << (double)(clock() - start_time) << " ms" << endl;
#endif
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3924kb

input:

2
4
8 2 7 10
6
9 6 5 3 4 8

output:

6.7500000000000000
5.8333333333333330

result:

ok 2 numbers

Test #2:

score: 0
Accepted
time: 78ms
memory: 3988kb

input:

100000
3
948511478 739365502 813471668
3
881046825 27458122 398507422
3
987554257 399092415 924260278
3
984128569 125199021 716360525
3
529589236 45783262 313507287
3
645443456 85994112 226010681
3
914820717 228360911 572267310
3
418958362 56703604 195276041
3
64461646 26764720 26995581
3
914535039 ...

output:

833782882.6666666269302368
435670789.6666666865348816
770302316.6666666269302368
608562705.0000000000000000
296293261.6666666865348816
319149416.3333333134651184
571816312.6666666269302368
223646002.3333333432674408
39407315.6666666641831398
383253737.6666666865348816
734363638.6666666269302368
7799...

result:

ok 100000 numbers

Test #3:

score: -100
Wrong Answer
time: 21ms
memory: 3896kb

input:

10000
4
194123849 79274911 191162487 570110764
86
957917218 915359202 914726017 873273226 867724859 867674150 809652204 805531383 745262007 743835491 727071232 714782071 645394643 639432679 594879540 587173904 583418126 560538589 518721836 469558994 427721766 411582333 404948350 402948978 357228675 ...

output:

258668002.7500000000000000
499947495.3837209343910217
495489050.3529411554336548
511519421.8630136847496033
472025965.6999999880790710
543693608.2500000000000000
543366581.5161290168762207
254833443.1999999880790710
395528440.9743589758872986
502458665.3846153616905212
564217787.3333333730697632
479...

result:

wrong answer 2nd numbers differ - expected: '527118856.7555556', found: '499947495.3837209', error = '0.0515469'