QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#546282#8242. V-DiagramChuggWA 80ms3820kbC++201.1kb2024-09-03 22:09:532024-09-03 22:09:54

Judging History

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

  • [2024-09-03 22:09:54]
  • 评测
  • 测评结果:WA
  • 用时:80ms
  • 内存:3820kb
  • [2024-09-03 22:09:53]
  • 提交

answer

#include <bits/stdc++.h>

void solve() 
{
    int n;
    std::cin >> n;
    std::vector<int> a(n);
    std::vector<int64_t> pre(n + 1);
    int pos = -1;
    for (int i = 0; i < n; ++i) {
        std::cin >> a[i];
        pre[i + 1] = pre[i] + a[i];
    }
    for (int i = 1; i < n - 1; ++i) {
        if (a[i] > a[i - 1] && a[i] < a[i + 1]) {
            pos = i;
        }
    }
    int l = 0, r = n - 1, len = n;
    for (int i = 0; i < pos - 1; ++i) {
        if ((pre[n] - pre[i + 1]) * (n - l) >= (pre[n] - pre[l]) * (n - i + 1)) {
            l = i + 1;
        } else {
            break;
        }
    }
    for (int i = n - 1; i > pos + 1; --i) {
        if ((pre[i] - pre[0]) * (r + 1) >= (pre[r + 1] - pre[0]) * i) {
            r = i - 1;
        } else {
            break;
        }
    };
    std::cout.setf(std::ios::fixed);
    std::cout << std::setprecision(15) << double(pre[r + 1] - pre[l]) / (r - l + 1) << '\n';
}

int main() 
{
    std::cin.tie(nullptr)->std::ios::sync_with_stdio(false);
    
    int t;
    std::cin >> t;
    while(t--) {
        solve();
    }
    
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

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

output:

6.750000000000000
5.833333333333333

result:

ok 2 numbers

Test #2:

score: -100
Wrong Answer
time: 80ms
memory: 3820kb

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:

948511478.000000000000000
881046825.000000000000000
770302316.666666626930237
608562705.000000000000000
296293261.666666686534882
645443456.000000000000000
571816312.666666626930237
418958362.000000000000000
64461646.000000000000000
914535039.000000000000000
899726714.000000000000000
779975824.33333...

result:

wrong answer 1st numbers differ - expected: '833782882.6666666', found: '948511478.0000000', error = '0.1376001'