QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#627639#8242. V-Diagramtaijinvjin#WA 0ms4032kbC++17999b2024-10-10 16:34:402024-10-10 16:34:41

Judging History

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

  • [2024-10-10 16:34:41]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:4032kb
  • [2024-10-10 16:34:40]
  • 提交

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 long 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 << (L + Ans) / (id - 2 + 3) << "\n";
    }else {
        std::cout << (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();
    }
}

詳細信息

Test #1:

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

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'