QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#687529#8242. V-Diagramcjpjh#WA 171ms4016kbC++201.0kb2024-10-29 19:30:572024-10-29 19:30:59

Judging History

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

  • [2024-10-29 19:30:59]
  • 评测
  • 测评结果:WA
  • 用时:171ms
  • 内存:4016kb
  • [2024-10-29 19:30:57]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;

#define int long long

void solve() {
    int n;
    cin >> n;

    vector<int> a(n);

    for(int i = 0; i < n; ++i) {
        cin >> a[i];
    }
    int p = -1;
    for(int i = 1; i < n - 1; ++i) {
        if(a[i] > a[i - 1] && a[i] < a[i + 1]) {
            p = i;
            break;
        }
    }

    double ans = 0;

    int sum = 0, num = 0;
    for(int i = 0; i <= p; ++i) {
        sum += a[i];
        num++;
    }
    for(int i = p + 1; i < n; ++i) {
        sum += a[i];
        num++;
        ans = max(ans, 1.0 * sum / num);
    }
    sum = 0, num = 0;
    for(int i = n - 1; i >= p; --i) {
        sum += a[i];
        num++;
    }
    for(int i = p - 1; i >= 0; --i) {
        sum += a[i];
        num++;
        ans = max(ans, 1.0 * sum / num);
    }
    cout << fixed << setprecision(20);
    cout << ans << "\n";
}

signed main() {
    int t = 1;
    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: 3792kb

input:

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

output:

6.75000000000000000000
5.83333333333333303727

result:

ok 2 numbers

Test #2:

score: -100
Wrong Answer
time: 171ms
memory: 4016kb

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.00000000000000000000
881046825.00000000000000000000
987554257.00000000000000000000
984128569.00000000000000000000
529589236.00000000000000000000
645443456.00000000000000000000
914820717.00000000000000000000
418958362.00000000000000000000
64461646.00000000000000000000
914535039.000000000000...

result:

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