QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#772590#8242. V-DiagramjamotWA 124ms3948kbC++141.5kb2024-11-22 20:32:082024-11-22 20:32:15

Judging History

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

  • [2024-11-22 20:32:15]
  • 评测
  • 测评结果:WA
  • 用时:124ms
  • 内存:3948kb
  • [2024-11-22 20:32:08]
  • 提交

answer

#include <bits/stdc++.h>
#include <iomanip>
#include <vector>
using namespace std;
typedef long long ll;
// #define int long long
typedef pair<int, int> P;
const int MAX_N = 1e5 + 5;
const int mod = 1e9 + 7;
int a[MAX_N];

void solve()
{
    int n;
    cin >> n;
    vector<P> v;
    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
    }
    int sum = 0;
    int cnt = 0;
    for (int i = 0; i < n; i++)
    {
        sum += a[i];
        cnt++;
        if (i + 1 < n && a[i + 1] > a[i])
        {
            for (int j = i + 1; j < n; j++)
            {
                // cout << j << ' ' << i + 1 << endl;
                // 8 2 7 10
                sum += a[j];
                cnt++;
                // cout << "j+1: " << j + 1 << ' ' << "n:" << n << endl;
                if ((j + 1 < n && a[j + 1] < a[j])||j==n-1)
                {
                    v.push_back({sum, cnt});
                    sum = 0;
                    cnt = 0;
                    i = j;
                    break;
                }
            }
        }
    }
    sort(v.rbegin(), v.rend());
    // if (!v.empty())
    cout << fixed << setprecision(10) << static_cast<double>(v[0].first) / v[0].second << endl;
    // else
    // cout << "为空" << endl;
}

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    int t = 1;
    cin >> t;
    while (t--)
    {
        solve();
    }
    return 0;
}

详细

Test #1:

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

input:

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

output:

6.7500000000
5.8333333333

result:

ok 2 numbers

Test #2:

score: -100
Wrong Answer
time: 124ms
memory: 3876kb

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:

-597872882.6666666269
435670789.6666666865
-661353448.6666666269
608562705.0000000000
296293261.6666666865
319149416.3333333135
571816312.6666666269
223646002.3333333433
39407315.6666666642
383253737.6666666865
-697292126.6666666269
-651679941.0000000000
490276408.3333333135
574448414.0000000000
337...

result:

wrong answer 1st numbers differ - expected: '833782882.6666666', found: '-597872882.6666666', error = '1.7170606'