QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#663507#8037. Gambler's RuincrychicWA 1ms4080kbC++171.8kb2024-10-21 15:56:562024-10-21 15:56:56

Judging History

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

  • [2024-10-21 15:56:56]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:4080kb
  • [2024-10-21 15:56:56]
  • 提交

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;

void solve() {
    int n;
    cin >> n;
    long double ans = -1e18;
    vector<pair<long double , int>  > p(n + 1);
    vector<ll> prec(n + 1);
    for(int i = 1;i <= n ;i ++){
        long double x;
        cin >> x;
        p[i].first = x;
        // cout << p[i].first << '\n';
        cin >> p[i].second;
    }
    // sort(c.begin() + 1,c.end(),[&](int x,int y)->bool{
    //     return p[x] < p[y];
    // });
    sort(p.begin() + 1,p.end());
    // for(int i = 1;i <= n;i ++){
    //     cout << p[i].first << ' ' << p[i].second << '\n';
    // }
    for(int i = 1;i <= n;i ++){
        prec[i] = prec[i - 1] + p[i].second;
    }
    int r = n + 1;
    for(int i = 1;i <= n;i ++){
        long double maxval = prec[i] / (1 - p[i].first);
        // cout << maxval << ' ';
        while(r - 1 >= 1){
            long double val = (prec[n] - prec[r - 2]) / p[r - 1].first;
            // cout << val << '\n';
            if(val <= maxval) r --;
            else break;
        }
        ans = max(ans,prec[i] + prec[n] - prec[r - 1] - maxval);
        // cout << i << ' ' << r << ' '  << ans << '\n';
    }
    int l = 0;
    for(int i = n;i >= 1;i --){
        long double maxval = (prec[n] - 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;
        }
        ans = max(ans,prec[n] - 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: 0ms
memory: 3836kb

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

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: 1ms
memory: 4072kb

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

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

input:

1
0.5 100

output:

0.0000000000

result:

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

Test #6:

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

input:

3
0.4 100
0.6 100
0.6 100

output:

33.3333333333

result:

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