QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#524585#8037. Gambler's RuinMCdycWA 0ms4000kbC++23997b2024-08-19 20:24:292024-08-19 20:24:29

Judging History

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

  • [2024-08-19 20:24:29]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:4000kb
  • [2024-08-19 20:24:29]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
#define all(a) a.begin(), a.end()
int main()
{
    int n;
    cin >> n;
    vector<pair<double, int>> a(n);
    int sum = 0;
    int cntx = 0;
    int cnty = 0;
    for (int i = 0; i < n; i++)
    {
        cin >> a[i].first >> a[i].second;
        sum += a[i].second;
    }
    a.emplace_back(1, 0);
    a.emplace_back(0, 0);
    sort(all(a), greater());
    double ans = 0;
    int r = n + 1;
    double sy = 0;
    for (int i = 0; a[i].first > 0; i++)
    {
        cntx += a[i].second;
        double x = 1 / a[i].first;
        double sx = x * cntx;
        while (sy <= sx && a[r].first < 1)
        {
            ans = max(ans, cnty + cntx - sx);
            cnty += a[r].second;
            double y = 1 / (1 - a[r].first);
            sy = y * cnty;
            r--;
        }
        ans = max(ans, cnty + cntx - max(sx, sy));
    }
    cout << fixed << setprecision(12) << ans << "\n";
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

2
1 15
0 10

output:

10.000000000000

result:

ok found '10.0000000', expected '10.0000000', error '0.0000000'

Test #2:

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

input:

3
0.4 100
0.5 100
0.6 100

output:

33.333333333333

result:

ok found '33.3333333', expected '33.3333333', error '0.0000000'

Test #3:

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

input:

1
0 1

output:

0.000000000000

result:

ok found '0.0000000', expected '0.0000000', error '-0.0000000'

Test #4:

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

input:

2
1 0
1 100

output:

0.000000000000

result:

ok found '0.0000000', expected '0.0000000', error '-0.0000000'

Test #5:

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

input:

1
0.5 100

output:

0.000000000000

result:

ok found '0.0000000', expected '0.0000000', error '-0.0000000'

Test #6:

score: -100
Wrong Answer
time: 0ms
memory: 3764kb

input:

3
0.4 100
0.6 100
0.6 100

output:

33.333333333333

result:

wrong answer 1st numbers differ - expected: '0.0000000', found: '33.3333333', error = '33.3333333'