QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#627643#8242. V-Diagramtaijinvjin#WA 0ms3800kbC++171013b2024-10-10 16:35:322024-10-10 16:35:32

Judging History

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

  • [2024-10-10 16:35:32]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3800kb
  • [2024-10-10 16:35:32]
  • 提交

answer

#include <bits/stdc++.h>

void solve() {
    int n;
    std::cin >> n;
    std::vector<int> a(n + 1);
    int id = 0;
    for (int i = 1; i <= n; i ++) {
        std::cin >> a[i];
    }
    
    for (int i = 2; i <= n - 1; i ++) {
        if (a[i] < a[i - 1] && a[i] < a[i + 1]) id = i, i = n - 1;
    }
    
    long double Ans = (a[id] + a[id - 1] + a[id + 1]);

    long double L = 0, R = 0;
    for (int i = 1; i < id - 1; i ++) L += a[i];
    for (int i = id + 2; i <= n; i ++) R += a[i];
    if ((R + Ans) / (3 + n - id - 1) > 1.0 * L / (id - 2)) {
        std::cout << (R + Ans) / (3 + n - id - 1) << "\n";
    }else if ((L + Ans) / (id - 2 + 3) > 1.0 * R / (n - id - 1) ) {
        std::cout << 1.0 * (L + Ans) / (id - 2 + 3) << "\n";
    }else {
        std::cout << 1.0 * (Ans + L + R) / n << "\n";
    }
}

signed main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    int T = 1;
    std::cin >> T;
    while (T --) {
        solve();
    }
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

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

output:

6.75
5.83333

result:

wrong answer 2nd numbers differ - expected: '5.8333333', found: '5.8333300', error = '0.0000006'