QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#627098#8242. V-Diagramzzfs#WA 0ms3940kbC++14917b2024-10-10 14:44:192024-10-10 14:44:19

Judging History

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

  • [2024-10-10 14:44:19]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3940kb
  • [2024-10-10 14:44:19]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 3e5 + 5;

int a[N];
int n;

void solve()
{
    cin >> n;

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

    ll sum = 0;
    double ans = 0;

    sum = 0;
    for (int i = 1; i <= n; i++)
    {
        sum += a[i];
        if (i > p)
            ans = max(ans, 1.0 * sum / i);
    }

    sum = 0;
    for (int i = n; i >= 1; i--)
    {
        sum += a[i];
        if (i < p)
            ans = max(ans, 1.0 * sum / (n - i + 1));
    }

    cout << fixed << setprecision(15) << ans << endl;
}

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

    int t = 1;
    cin >> t;
    while (t--)
        solve();

    return 0;
}

詳細信息

Test #1:

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

input:

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

output:

5.666666666666667
7.500000000000000

result:

wrong answer 1st numbers differ - expected: '6.7500000', found: '5.6666667', error = '0.1604938'