QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#664751#8037. Gambler's RuincrychicWA 540ms76548kbC++172.0kb2024-10-21 22:09:332024-10-21 22:09:33

Judging History

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

  • [2024-10-21 22:09:33]
  • 评测
  • 测评结果:WA
  • 用时:540ms
  • 内存:76548kb
  • [2024-10-21 22:09:33]
  • 提交

answer

#include<bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int N = 1e5 + 10;
const int INF = 1e9;
const long double eps = 1e-7;
void solve() {
    int n;
    cin >> n;
    long double ans = 0;
    vector<pair<long double, int>> pp(n + 1);
    vector<pair<long double, ll>> p;
    vector<ll> prec(n + 1);
    for(int i = 1;i <= n ;i ++){
        double x;
        cin >> x;
        pp[i].first = x;
        cin >> pp[i].second;
    }
    p.push_back({0,0});
    sort(pp.begin() + 1,pp.end());
    long double tmp1 = 0;
    ll tmp2 = pp[1].second;
    for(int i = 2;i <= n;i ++){
        if(pp[i].first - pp[i - 1].first < eps){
            tmp2 += pp[i].second;
        }else {
            p.push_back({pp[i - 1].first,tmp2});
            tmp2 = pp[i].second;
        }
    }
    if(tmp2){
        p.push_back({pp[n].first,tmp2});
    }
    for(int i = 1;i <= p.size() - 1;i ++){
        prec[i] = prec[i - 1] + p[i].second;
    }
    int len = p.size() - 1;
    int r = len + 1;
    for(int i = 1;i <= len;i ++){
        long double maxval = prec[i] / (1 - p[i].first);
        while(r - 1 >= 1){
            long double val = (prec[len] - prec[r - 2]) / p[r - 1].first;
            if(val <= maxval) r --;
            else break;
        }
        if(r <= i) break;
        ans = max(ans,prec[i] + prec[len] - prec[r - 1] - maxval);
    }
    int l = 0;
    for(int i = n;i >= 1;i --){
        long double maxval = (prec[len] - prec[i - 1]) / p[i].first;
        while(l + 1 <= n){
            long double val = prec[l + 1] / (1 - p[l + 1].first);
            if(val < maxval) l ++;
            else break;
        }
        if(l >= i) break;
        ans = max(ans,prec[len] - prec[i - 1] + prec[l] - maxval);
    }
    cout << fixed << setprecision(10) << ans << "\n";
}
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);
    
    int t = 1;
    // cin >> t;
    while(t -- ) {
        solve();
    }

    return 0;
}

详细

Test #1:

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

input:

2
1 15
0 10

output:

10.0000000000

result:

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

Test #2:

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

input:

3
0.4 100
0.5 100
0.6 100

output:

33.3333333333

result:

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

Test #3:

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

input:

1
0 1

output:

0.0000000000

result:

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

Test #4:

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

input:

2
1 0
1 100

output:

0.0000000000

result:

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

Test #5:

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

input:

1
0.5 100

output:

0.0000000000

result:

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

Test #6:

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

input:

3
0.4 100
0.6 100
0.6 100

output:

0.0000000000

result:

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

Test #7:

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

input:

3
0.2 100
0.2 100
0.8 100

output:

50.0000000000

result:

ok found '50.0000000', expected '50.0000000', error '0.0000000'

Test #8:

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

input:

2
0.999999 1000000
0.999998 2

output:

0.9999990000

result:

ok found '0.9999990', expected '0.9999990', error '0.0000000'

Test #9:

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

input:

2
0 100000
0.000001 1

output:

0.0000000000

result:

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

Test #10:

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

input:

2
0 1000000000
0.000001 1

output:

1.0000000000

result:

ok found '1.0000000', expected '1.0000000', error '0.0000000'

Test #11:

score: -100
Wrong Answer
time: 540ms
memory: 76548kb

input:

1000000
0.375733 595197307
0.505261 377150668
0.517039 15795246
0.448099 228176467
0.529380 871983979
0.905546 876268308
0.095891 272104456
0.500302 916153337
0.128705 355768079
0.070600 78747362
0.444107 466118868
0.194987 298494965
0.462293 593292779
0.287909 838058266
0.237226 934603199
0.391909 ...

output:

499855763379331.0000000000

result:

wrong answer 1st numbers differ - expected: '85718080941203.0156250', found: '499855763379331.0000000', error = '4.8313924'