QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#633072#8242. V-DiagramLateRegistration#WA 186ms3812kbC++171.0kb2024-10-12 14:29:152024-10-12 14:29:16

Judging History

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

  • [2024-10-12 14:29:16]
  • 评测
  • 测评结果:WA
  • 用时:186ms
  • 内存:3812kb
  • [2024-10-12 14:29:15]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;

void solve() {
    int n;
    cin >> n;
    vector<int> a(n);
    for (int &x : a) {
        cin >> x;
    }
    int p;
    for (int i = 0; i < n; i++) {
        if (i == n - 1 || a[i] < a[i + 1]) {
            p = i;
            break;
        }
    }
    double l = 0, r = 1e9;
    for (int _ = 0; _ < 100; _++) {
        double mid = (l + r) / 2;
        double mx = a[p] - mid, sum = 0;
        for (int i = p; i >= 0; i--) {
            sum += a[i] - mid;
            mx = max(mx, sum);
        }
        sum = 0;
        double mx2 = 0;
        for (int i = p + 1; i < n; i++) {
            sum += a[i] - mid;
            mx2 = max(mx2, sum);
        }
        if (mx + mx2 > 0) {
            l = mid;
        } else {
            r = mid;
        }
    }
    cout << l << "\n";
}

int main() {
    ios::sync_with_stdio(0), cin.tie(0);
    int T;
    cin >> T;
    cout << fixed << setprecision(9);
    while (T--) {
        solve();
    }
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

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

output:

6.750000000
5.833333333

result:

ok 2 numbers

Test #2:

score: -100
Wrong Answer
time: 186ms
memory: 3812kb

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:

843938489.999999881
454252473.499999940
770302316.666666627
608562704.999999881
296293261.666666627
365718783.999999940
571816312.666666627
237830982.999999970
45613182.999999993
474479951.499999940
742247811.999999881
779975824.333333254
503399231.499999940
645879534.499999881
432761814.999999940
6...

result:

wrong answer 1st numbers differ - expected: '833782882.6666666', found: '843938489.9999999', error = '0.0121802'