QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#725927#8037. Gambler's RuingjlcccRE 1ms8072kbC++201.6kb2024-11-08 20:42:082024-11-08 20:42:09

Judging History

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

  • [2024-11-08 20:42:09]
  • 评测
  • 测评结果:RE
  • 用时:1ms
  • 内存:8072kb
  • [2024-11-08 20:42:08]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
typedef long long ll;
typedef pair<ll,ll>pll;
const ll INF=0x3f3f3f3f;
const ll MO9=998244353;
const ll MO1=1e9+7;
const ll MO=MO9;
const int N=5e5+5;
ll n,m;
ll s[N];
double p[N];
struct node{
    double p;
    ll c;
}a[N],b[N];
void solve(){
    cin>>n;
    for(int i=1;i<=n;i++)cin>>b[i].p>>b[i].c;
    sort(b+1,b+n+1,[=](node a,node b){
        return a.p>b.p;
    });
    int t=0;
    b[0].p=-1.0;
    for(int i=1;i<=n;i++){
        if(b[i].p==b[i-1].p){
            a[t].c+=b[i].c;
        }
        else a[++t]=b[i];
    }
    n=t;
    for(int i=1;i<=n;i++){
        // cin>>s[i];
        s[i]=a[i].c;
        s[i]+=s[i-1];
        p[i]=a[i].p;
    }
    double ans=0;
    for(int i=1;i<n;i++){
        double tot=1.0*s[i]/p[i];
        // cout<<tot<<' ';
        // cout<<n<<' ';
        // cout<<tot<<'\n';
        int res=n;
        int l=2,r=n;
        while(l<=r){
            int mid=l+r>>1;
            double k=1.0*(s[n]-s[mid-1])/(1.0-p[mid]);
            double ab=s[n]-s[mid-1]+s[i];
            if(k<=tot){
                res=mid;
                ans=max(ans,ab-tot);
                r=mid-1;
            }
            else{
                ans=max(ans,ab-k);
                l=mid+1;
            }
        }

    }
    cout<<fixed<<setprecision(6)<<ans<<'\n';
}
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0),cout.tie(0);
    int ttt=1;
    // cin>>ttt;
    while(ttt--)
    solve();
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

2
1 15
0 10

output:

10.000000

result:

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

Test #2:

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

input:

3
0.4 100
0.5 100
0.6 100

output:

33.333333

result:

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

Test #3:

score: 0
Accepted
time: 1ms
memory: 8008kb

input:

1
0 1

output:

0.000000

result:

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

Test #4:

score: 0
Accepted
time: 1ms
memory: 8064kb

input:

2
1 0
1 100

output:

0.000000

result:

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

Test #5:

score: 0
Accepted
time: 1ms
memory: 8012kb

input:

1
0.5 100

output:

0.000000

result:

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

Test #6:

score: 0
Accepted
time: 1ms
memory: 7936kb

input:

3
0.4 100
0.6 100
0.6 100

output:

0.000000

result:

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

Test #7:

score: 0
Accepted
time: 1ms
memory: 8004kb

input:

3
0.2 100
0.2 100
0.8 100

output:

50.000000

result:

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

Test #8:

score: 0
Accepted
time: 1ms
memory: 8072kb

input:

2
0.999999 1000000
0.999998 2

output:

0.999999

result:

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

Test #9:

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

input:

2
0 100000
0.000001 1

output:

0.000000

result:

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

Test #10:

score: 0
Accepted
time: 1ms
memory: 8068kb

input:

2
0 1000000000
0.000001 1

output:

1.000000

result:

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

Test #11:

score: -100
Runtime Error

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:


result: