QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#743938#8037. Gambler's Ruinucup-team3548#WA 0ms3908kbC++201.2kb2024-11-13 20:22:032024-11-13 20:22:13

Judging History

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

  • [2024-11-13 20:22:13]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3908kb
  • [2024-11-13 20:22:03]
  • 提交

answer

#include <bits/stdc++.h>

using namespace std;
using ll = long long;

const int inf = 2e9 + 7;

void solve() {
    int n;
    cin >> n;
    vector<pair<double, int> > a(n);
    for (auto &[p, c] : a) {
        cin >> p >> c;
    }
    sort(a.begin(), a.end());
    reverse(a.begin(), a.end());
    ll sum1 = 0, sum2 = 0;
    double ans = 0;
    for (int i = 0, j = n - 1; i < n; ++i) {
        double x = 1 / a[i].first;
        sum1 += a[i].second;
        double y = 0;
        while (i < j && a[j].first != 1 && 1 / (1 - a[j].first) * (sum2 + a[j].second) < sum1 * x) {
            sum2 += a[j].second;
            y = 1 / (1 - a[j].first);
            j--;
        }
        if (y != 0) {
            ans = max(ans, sum1 + sum2 - max(sum1 * x, sum2 * y));
        }
        if (i < j) {
            y = 1 / (1 - a[j].first);
            ans = max(ans, sum1 + sum2 + a[j].second - max(sum1 * x, (sum2 + a[j].second) * y));
        } else {
            break;
        }
    }
    cout << fixed << setprecision(12) << ans << "\n";
}

int main(void) {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    int t = 1;
    // cin >> t;
    while (t--) {
        solve();
    }
    return 0;
}

詳細信息

Test #1:

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

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: 3756kb

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: 3908kb

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: 3868kb

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: 3772kb

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: 3772kb

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'