QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#607592#8037. Gambler's RuinlongyinWA 2ms10120kbC++201.0kb2024-10-03 15:27:352024-10-03 15:27:35

Judging History

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

  • [2024-10-03 15:27:35]
  • 评测
  • 测评结果:WA
  • 用时:2ms
  • 内存:10120kb
  • [2024-10-03 15:27:35]
  • 提交

answer

#include <bits/stdc++.h>
//#define int long long
#define endl "\n"
using namespace std;

using ll = long long;
const double INF = 1e15;
const int N = 1e6 + 5;

pair<double, ll> a[N];
double p[N];
ll c[N], sc[N];

double getPrice(int l, int r, int n) {
    return sc[l] + sc[n] - sc[r - 1] - max(sc[l] * (1 / (1 - p[l])), (sc[n] - sc[r - 1]) * (1 / p[r]));
}

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

    int n;
    cin >> n;
    for (int i = 1; i <= n; i++) {
        cin >> a[i].first >> a[i].second;
    }
    sort(a + 1, a + n + 1);
    for (int i = 1; i <= n; i++) {
        p[i] = a[i].first;
        c[i] = a[i].second;
        sc[i] = sc[i - 1] + c[i];
    }

    double ans = 0;
    for (int l = 1, r = n; l <= n; l++) {
        double x = getPrice(l, r, n);
        while (l <= r - 1 && getPrice(l, r - 1, n) >= x) {
            r--;
            x = getPrice(l, r, n);
        }
        ans = max(ans, x);
    }
    cout << fixed << setprecision(20) << ans << endl;

    return 0;
}

詳細信息

Test #1:

score: 100
Accepted
time: 2ms
memory: 10120kb

input:

2
1 15
0 10

output:

10.00000000000000000000

result:

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

Test #2:

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

input:

3
0.4 100
0.5 100
0.6 100

output:

33.33333333333331438553

result:

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

Test #3:

score: 0
Accepted
time: 2ms
memory: 10048kb

input:

1
0 1

output:

0.00000000000000000000

result:

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

Test #4:

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

input:

2
1 0
1 100

output:

0.00000000000000000000

result:

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

Test #5:

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

input:

1
0.5 100

output:

0.00000000000000000000

result:

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

Test #6:

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

input:

3
0.4 100
0.6 100
0.6 100

output:

33.33333333333331438553

result:

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