QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#551870#8242. V-DiagramAshbourne#WA 72ms4008kbC++23834b2024-09-07 18:39:072024-09-07 18:39:07

Judging History

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

  • [2024-09-07 18:39:07]
  • 评测
  • 测评结果:WA
  • 用时:72ms
  • 内存:4008kb
  • [2024-09-07 18:39:07]
  • 提交

answer

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

void solve() {
    int n;
    cin >> n;
    vector<int> a(n);
    for (auto &e: a) cin >> e;

    int m = 0;
    for (int i = 1; i < n; i++) {
        if (a[i-1] < a[i]) break;
        m++;
    }
    assert(m != 0 && m != n-1);

    vector<int> ps(n+1, 0);
    for (int i = 0; i < n; i++) {
        ps[i+1] = ps[i] + a[i];
    }

    double ans = 0;
    for (int i = 0; i < m; i++) {
        ans = max(ans, (double)(ps[n] - ps[i]) / (n - i));
    }
    for (int i = m+1; i < n; i++) {
        ans = max(ans, (double)(ps[i+1]) / (i+1));
    }

    cout << fixed << setprecision(12) << ans << '\n';
}

int main() {
    cin.tie(0)->sync_with_stdio(0);

    int t;
    cin >> t;
    for (; t; t--) solve();

    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

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

output:

6.750000000000
5.833333333333

result:

ok 2 numbers

Test #2:

score: -100
Wrong Answer
time: 72ms
memory: 3740kb

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:

0.000000000000
435670789.666666666657
0.000000000000
608562705.000000000000
296293261.666666666657
319149416.333333333343
571816312.666666666686
223646002.333333333328
39407315.666666666668
383253737.666666666657
0.000000000000
0.000000000000
490276408.333333333343
574448414.000000000000
337980292.0...

result:

wrong answer 1st numbers differ - expected: '833782882.6666666', found: '0.0000000', error = '1.0000000'