QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#612791#8242. V-DiagramLeoGWA 1ms3912kbC++201.0kb2024-10-05 12:56:542024-10-05 12:56:55

Judging History

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

  • [2024-10-05 12:56:55]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3912kb
  • [2024-10-05 12:56:54]
  • 提交

answer

#include<bits/stdc++.h>
#define ll              long long 
#define all(v)          v.begin(),v.end()
#define ld              long double
#define pll             std::pair<ll,ll>
#define pi              std::pair<int,int>
#define vi              std::vector<int>
#define vll             std::vector<ll>


void solve(){
    int n;
    std::cin >> n;
    vll a(n), pre(n + 1);
    for (int i = 0; i < n; i++) {
        std::cin >> a[i];
        pre[i + 1] = pre[i] + a[i];
    }
    int i;
    for (i = 1; i < n - 1; i++) {
        if (a[i - 1] > a[i] && a[i] < a[i + 1]) {
            break;
        }
    }
    ld avg = pre[n] / (ld)n;
    avg = std::max(avg, (pre[n] - pre[i - 1]) / (ld)(n - i + 1));
    avg = std::max(avg, (pre[i + 2] / (ld)(i + 2)));
    avg = std::max(avg, (a[i - 1] + a[i] + a[i + 1]) / (ld)3);
    std::cout << avg << std::endl;

    

}
int 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: 1ms
memory: 3912kb

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'