QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#189630#2878. Journey in FogIsaacMorisWA 1ms3828kbC++171.2kb2023-09-27 18:48:292023-09-27 18:48:30

Judging History

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

  • [2023-09-27 18:48:30]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3828kb
  • [2023-09-27 18:48:29]
  • 提交

answer

#include<iostream>
#include <bits/stdc++.h>

#define ll long long
#define ld long double
#define IO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;
const int N = 3e5 + 5, inf = 2e9;

void doWork() {
    int n, l, v;
    cin >> n >> l >> v;
    vector<int> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    cout << fixed << setprecision(9);
    if (n == 1) {
        if (a[0] >= v) {
            cout << (ld) l / a[0];
        } else {
            cout << (ld) 2 * l / (a[0] + v);
        }
        return;
    }

    sort(a.begin(), a.end());
    ld sum1 = 0, sum2 = 0;
    for (auto i: a) {
        sum1 += (ld) 1 / (i + v);
        sum2 += (ld) i / (i + v);
    }

    ld ans = 1e9;
    ld t = 0;
    ans = min(ans, t + 2 * (sum1 * l - t * sum2) / n);

    while (!a.empty()) {
        t = (ld) l / a.back();
        sum2 -= (ld) a.back() / (a.back() + v);
        sum1 -= (ld) 1 / (a.back() + v);
        a.pop_back();

        ans = min(ans, t + 2 * (sum1 * l - t * sum2) / n);
    }
    cout << ans;
}


int main() {
    IO
    int t = 1;
    //   cin >> t;
    for (int i = 1; i <= t; i++) {
        //  cout << "Case #" << i << ": ";
        doWork();
    }
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 1ms
memory: 3564kb

input:

1 1000 30
10

output:

50.000000000

result:

ok found '50.000000000', expected '50.000000000', error '0.000000000'

Test #2:

score: 0
Accepted
time: 0ms
memory: 3624kb

input:

1 1000 10
30

output:

33.333333333

result:

ok found '33.333333333', expected '33.333333333', error '0.000000000'

Test #3:

score: 0
Accepted
time: 1ms
memory: 3712kb

input:

4 1000 20
10 20 30 40

output:

46.250000000

result:

ok found '46.250000000', expected '46.250000000', error '0.000000000'

Test #4:

score: 0
Accepted
time: 1ms
memory: 3632kb

input:

2 68 7
4 9

output:

10.431818182

result:

ok found '10.431818182', expected '10.431818182', error '0.000000000'

Test #5:

score: 0
Accepted
time: 1ms
memory: 3828kb

input:

5 636 86
41 48 59 80 83

output:

8.693995392

result:

ok found '8.693995392', expected '8.693995392', error '0.000000000'

Test #6:

score: 0
Accepted
time: 0ms
memory: 3596kb

input:

10 14292 401
28 74 253 272 338 692 751 770 803 909

output:

37.259943499

result:

ok found '37.259943499', expected '37.259943499', error '0.000000000'

Test #7:

score: -100
Wrong Answer
time: 1ms
memory: 3752kb

input:

10 456181726 218016
136026 204990 312262 507994 650490 760622 777222 811022 814221 915133

output:

1121.295974776

result:

wrong answer 1st numbers differ - expected: '1093.7615491', found: '1121.2959748', error = '0.0251741'