QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#771520#8037. Gambler's RuincaiwenWA 1243ms91808kbC++142.1kb2024-11-22 13:49:552024-11-22 13:49:55

Judging History

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

  • [2024-11-22 13:49:55]
  • 评测
  • 测评结果:WA
  • 用时:1243ms
  • 内存:91808kb
  • [2024-11-22 13:49:55]
  • 提交

answer

#include<bits/stdc++.h>
#define int long long
#define ull unsigned long long
#define ls(k) (k)<<1
#define rs(k) (k)<<1|1
#define debug(x) cout<<#x<<"="<<x<<endl
using namespace std;
const int inf=0x3f3f3f3f3f3f3f3f;
const int mod=0;
typedef pair<int,int> pii;
typedef pair<double,int> pdi;
#define _ 1000006
pdi e[_];
int n;
double x[_],y[_],dx[_],dy[_];
int px,py,sx[_],sy[_],tx,ty;
const double eps=1e-8;
inline void subtask(){
    map<double,int> ma;
    cin>>n;
    int tag=0;
    for(int i=1;i<=n;i++){
        double p;
        int c;
        cin>>p>>c;
        int tar=ma[p];
        if(!tar){
            tag++;
            ma[p]=tag;
            tar=tag;
            e[tar].first=p;
        }
        e[tar].second+=c; 
    }
    n=tag;
    sort(e+1,e+n+1,[](pdi x,pdi y){return x.first>y.first;});
    for(int i=1;i<=n;i++){
        if(fabs(e[i].first)<eps) break;
        else px++,x[i]=1.0/e[i].first;
    }
    py=n+1;
    for(int i=n;i>=1;i--){
        double p=1-e[i].first;
        if(fabs(p)<eps) break;
        else py=i,y[i]=1.0/p;
    }
    tx=1,ty=n;
    for(int i=1;i<=px;i++){
        sx[i]=sx[i-1]+e[i].second,dx[i]=sx[i]-sx[i]*x[i];
        if(dx[i]>dx[tx]) tx=i;
    }
    for(int i=n;i>=py;i--){
        sy[i]=sy[i+1]+e[i].second,dy[i]=sy[i]-sy[i]*y[i];
        if(dy[i]>dy[ty]) ty=i;
    }
    bool flag=0;
    double aans;
    for(int i=0;i<=px;i++){
        int l=max(i+1,py),r=n,ans=n+1;
        while(l<=r){
            int mid=(l+r)>>1;
            if(sy[mid]*y[mid]<sx[i]*x[i]){
                ans=mid;
                r=mid-1;
            }else l=mid+1;
        }
        double loc=sx[i]-sx[i]*x[i];
        if(ty>i) loc=max(loc,sx[i]+sy[ty]-max(sx[i]*x[i],sy[ty]*y[ty]));
        loc=max(loc,sx[i]+sy[ans]-max(sx[i]*x[i],sy[ans]*y[ans]));
        //debug(ans);
        if(!flag){
            flag=1;
            aans=loc;
        }else aans=max(aans,loc);
    }
    printf("%.10lf",aans);
}
signed main(){
    //ios::sync_with_stdio(false);
    int t=1;//cin>>t;
    while(t--) subtask();
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

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

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

input:

1
0 1

output:

0.0000000000

result:

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

Test #4:

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

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

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

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

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

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

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

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: 1243ms
memory: 91808kb

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:

85717855511929.0000000000

result:

wrong answer 1st numbers differ - expected: '85718080941203.0156250', found: '85717855511929.0000000', error = '0.0000026'