QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#235823#6609. Scholomance Academywhsyhyyh#AC ✓247ms23484kbC++141.4kb2023-11-03 10:26:572023-11-03 10:26:57

Judging History

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

  • [2023-11-03 10:26:57]
  • 评测
  • 测评结果:AC
  • 用时:247ms
  • 内存:23484kb
  • [2023-11-03 10:26:57]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
#define db double
const int N = 1e6+9;

char s[10];
int a[N],n;
bool cmp(int x,int y){
    return abs(x)<abs(y);
}
double fpr(db tp,db fp,db tn,db fn){
    if(tn+fp==0) return 1;
    return fp/(tn+fp);
}
double tpr(db tp,db fp,db tn,db fn){
    if(tp+fn==0) return 1;
    return tp/(tp+fn);
}
int m;
struct pp{db ff,tt;}b[N];
bool cmpp(pp x,pp y){
    return x.ff==y.ff?(x.tt>y.tt):(x.ff<y.ff);
}
int main(){
    scanf("%d",&n);int cnt=0;
    for(int i=1;i<=n;i++){
        scanf("%s%d",s,&a[i]);
        if(s[0]=='-') a[i]=-a[i],cnt++;
    }
    sort(a+1,a+n+1,cmp);
    double tp=n-cnt,fp=cnt,tn=0,fn=0;
    m=0;b[++m]=(pp){fpr(tp,fp,tn,fn),tpr(tp,fp,tn,fn)};
        // printf("%.8lf %.8lf\n",b[m].ff,b[m].tt);
    for(int i=1;i<=n;i++){
        if(a[i]<0) tn++,fp--;
        if(a[i]>0) tp--,fn++;
        while(i<n&&abs(a[i+1])==abs(a[i])){
            i++;
            if(a[i]<0) tn++,fp--;
            if(a[i]>0) tp--,fn++;
        }
        // printf("%lf %lf %lf\n",fp,tn,fp);
        b[++m]=(pp){fpr(tp,fp,tn,fn),tpr(tp,fp,tn,fn)};
        // printf("%.8lf %.8lf\n",b[m].ff,b[m].tt);
    }
    sort(b+1,b+m+1,cmpp);
    b[++m]=(pp){1,0};
    double ans=0,c=0;
    for(int i=1;i<=m;i++){
        ans+=c*(b[i].ff-b[i-1].ff);
        c=max(c,b[i].tt);
    }
    printf("%.14lf\n",ans);
    return 0;
}

这程序好像有点Bug,我给组数据试试?

详细

Test #1:

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

input:

3
+ 2
- 3
- 1

output:

0.50000000000000

result:

ok found '0.500000000', expected '0.500000000', error '0.000000000'

Test #2:

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

input:

6
+ 7
- 2
- 5
+ 4
- 2
+ 6

output:

0.88888888888889

result:

ok found '0.888888889', expected '0.888888889', error '0.000000000'

Test #3:

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

input:

8
+ 34
+ 33
+ 26
- 34
- 38
+ 39
- 7
- 27

output:

0.56250000000000

result:

ok found '0.562500000', expected '0.562500000', error '0.000000000'

Test #4:

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

input:

2
+ 12345135
- 12345135

output:

0.00000000000000

result:

ok found '0.000000000', expected '0.000000000', error '-0.000000000'

Test #5:

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

input:

2
+ 4
- 3

output:

1.00000000000000

result:

ok found '1.000000000', expected '1.000000000', error '0.000000000'

Test #6:

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

input:

2
- 3
+ 4

output:

1.00000000000000

result:

ok found '1.000000000', expected '1.000000000', error '0.000000000'

Test #7:

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

input:

2
- 12
+ 11

output:

0.00000000000000

result:

ok found '0.000000000', expected '0.000000000', error '-0.000000000'

Test #8:

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

input:

2
+ 7
- 9

output:

0.00000000000000

result:

ok found '0.000000000', expected '0.000000000', error '-0.000000000'

Test #9:

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

input:

2
- 4
+ 4

output:

0.00000000000000

result:

ok found '0.000000000', expected '0.000000000', error '-0.000000000'

Test #10:

score: 0
Accepted
time: 90ms
memory: 9128kb

input:

1000000
+ 1
- 1
- 1
- 1
+ 1
- 1
+ 1
- 1
- 1
+ 1
+ 1
- 1
+ 1
- 1
- 1
+ 1
+ 1
+ 1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 1
+ 1
+ 1
+ 2
- 2
+ 2
+ 2
- 1
+ 1
- 2
+ 2
+ 1
+ 1
...

output:

0.24949178189850

result:

ok found '0.249491782', expected '0.249491782', error '0.000000000'

Test #13:

score: 0
Accepted
time: 118ms
memory: 8560kb

input:

999999
+ 20
- 6
+ 13
- 20
- 19
+ 17
+ 13
- 8
+ 3
+ 6
- 17
+ 17
+ 16
- 16
+ 8
+ 11
- 7
- 20
- 13
+ 6
- 7
+ 19
+ 10
- 5
- 9
- 16
- 17
+ 13
+ 7
+ 18
- 17
+ 13
+ 16
+ 10
+ 17
- 9
- 6
+ 11
- 7
+ 8
- 5
+ 20
- 18
+ 1
+ 8
- 9
+ 4
+ 5
+ 14
- 11
- 15
- 8
- 7
- 7
+ 15
+ 15
+ 8
- 3
+ 13
- 5
+ 9
- 14
+ 6
- 8
+ 3...

output:

0.47415371150088

result:

ok found '0.474153712', expected '0.474153712', error '0.000000000'

Test #14:

score: 0
Accepted
time: 114ms
memory: 7952kb

input:

1000000
+ 22
- 6
+ 13
- 20
- 19
+ 24
+ 24
- 15
+ 17
+ 3
+ 23
+ 20
- 17
+ 23
+ 16
- 21
- 22
+ 8
+ 11
- 23
+ 17
- 24
- 13
+ 6
- 7
+ 19
+ 21
- 14
+ 18
- 22
- 11
- 21
- 21
+ 13
+ 24
+ 20
+ 18
- 17
+ 13
+ 16
+ 10
+ 25
- 24
- 14
+ 7
- 15
+ 22
+ 8
- 5
+ 20
- 18
+ 1
+ 8
- 9
+ 4
+ 25
+ 1
- 9
- 9
- 14
+ 14
+ ...

output:

0.47954169616097

result:

ok found '0.479541696', expected '0.479541696', error '0.000000000'

Test #15:

score: 0
Accepted
time: 135ms
memory: 8460kb

input:

999999
- 595
+ 975
+ 320
- 300
+ 871
- 170
+ 103
- 360
+ 868
- 631
- 851
- 509
+ 725
+ 627
- 983
- 63
- 845
+ 367
+ 1000
- 980
- 846
- 605
- 987
+ 582
- 367
- 724
- 579
+ 944
+ 566
- 873
- 889
- 991
+ 562
+ 209
+ 625
+ 328
- 463
+ 673
+ 77
+ 365
- 275
+ 667
- 424
- 85
+ 942
+ 504
+ 447
- 90
+ 780
+ ...

output:

0.50035494122561

result:

ok found '0.500354941', expected '0.500354941', error '0.000000000'

Test #16:

score: 0
Accepted
time: 129ms
memory: 8844kb

input:

1000000
- 18
- 59
- 824
+ 193
- 373
- 462
- 707
+ 765
- 285
- 664
+ 186
- 374
- 360
+ 295
- 339
+ 144
- 88
+ 96
- 103
+ 809
- 453
- 624
- 509
- 435
+ 158
+ 503
+ 160
+ 194
- 579
+ 135
- 276
+ 605
- 564
- 549
- 219
- 246
- 399
- 893
+ 166
+ 749
- 551
+ 729
+ 787
- 507
+ 563
+ 222
+ 767
- 117
- 232
- ...

output:

0.49961580680244

result:

ok found '0.499615807', expected '0.499615807', error '0.000000000'

Test #17:

score: 0
Accepted
time: 193ms
memory: 19380kb

input:

999999
+ 649917
- 505960
- 144512
- 570407
+ 262265
- 623272
+ 743202
- 886356
- 199591
+ 951022
+ 966769
+ 770209
+ 256025
- 118843
+ 168738
+ 516944
+ 160812
- 283717
+ 254929
- 442969
- 897288
+ 74809
- 419482
- 845143
- 967020
+ 883637
- 767990
- 173181
+ 230007
+ 638724
- 950239
+ 836557
+ 7156...

output:

0.49993264747848

result:

ok found '0.499932647', expected '0.499932647', error '0.000000000'

Test #18:

score: 0
Accepted
time: 210ms
memory: 21288kb

input:

1000000
+ 750053
+ 923209
- 763652
- 396503
+ 84843
- 225264
+ 211824
- 199934
+ 199338
+ 972980
- 107119
- 690804
- 223468
+ 781874
- 35507
- 846803
- 681603
+ 211351
- 224207
+ 72103
- 962217
+ 425712
+ 992688
- 246076
- 768896
+ 369739
+ 238902
- 578540
+ 28399
+ 829998
- 893623
- 200097
+ 556996...

output:

0.50053220051752

result:

ok found '0.500532201', expected '0.500532201', error '0.000000000'

Test #19:

score: 0
Accepted
time: 226ms
memory: 23476kb

input:

999999
- 245903924
- 483230839
+ 108985430
+ 539249067
- 320800640
+ 848181362
+ 484237694
- 459595626
+ 979645696
- 948686855
- 70497963
+ 674887631
+ 782479996
- 668243716
+ 147438342
+ 435024955
- 154928249
- 389834034
+ 197879974
+ 739032367
+ 426010178
- 682896784
- 130246237
- 740749204
+ 8418...

output:

0.49941491126231

result:

ok found '0.499414911', expected '0.499414911', error '0.000000000'

Test #20:

score: 0
Accepted
time: 219ms
memory: 23484kb

input:

1000000
- 853247405
+ 441797910
- 766129524
- 685136985
+ 584459708
- 538159424
- 800344356
+ 124883688
+ 161535274
- 678914022
+ 567638902
- 633603171
+ 298109475
- 389464136
- 544651056
+ 437101725
- 294477595
+ 208671579
- 441015307
- 244456728
+ 484763083
+ 917286399
+ 531350532
- 353718014
+ 17...

output:

0.50045516708419

result:

ok found '0.500455167', expected '0.500455167', error '0.000000000'

Test #21:

score: 0
Accepted
time: 211ms
memory: 21344kb

input:

1000000
+ 6278775
+ 6076582
+ 5872033
- 5301138
+ 6417685
+ 6112374
+ 6197023
+ 5353843
- 4459159
- 5291583
+ 5441573
+ 6067621
- 4489765
+ 6025291
+ 6794592
- 4381371
- 5465451
- 4135215
- 4900908
- 4987148
- 5965095
- 4607027
+ 6326439
- 5421119
+ 5518925
+ 5957293
- 5484248
+ 5506751
- 4254534
- ...

output:

0.92074568753797

result:

ok found '0.920745688', expected '0.920745688', error '0.000000000'

Test #22:

score: 0
Accepted
time: 209ms
memory: 23400kb

input:

1000000
- 781328
+ 9314902
+ 9055461
+ 8346316
- 1429049
- 1184986
- 1528431
- 162650
+ 9089967
- 1207692
+ 8377161
- 468712
+ 10198601
+ 8530637
+ 9325112
- 1217371
+ 8766135
+ 9103679
+ 8852542
- 229999
+ 8836117
+ 9957897
- 567800
- 1250789
- 1612427
- 112108
+ 8489648
- 1301755
- 745317
+ 872436...

output:

1.00000000000000

result:

ok found '1.000000000', expected '1.000000000', error '0.000000000'

Test #23:

score: 0
Accepted
time: 247ms
memory: 23408kb

input:

1000000
- 9064819
- 8916397
+ 1173623
- 9021425
- 9141255
+ 1387882
+ 509522
+ 530250
+ 1743860
+ 1410003
- 9448471
- 8829125
+ 1731730
- 8613071
- 8384510
- 8878865
- 8624019
+ 342034
- 9866078
+ 1393572
+ 1142802
- 9500710
+ 547028
- 9281383
- 9543821
- 9515255
+ 770513
+ 1301904
+ 809391
- 809931...

output:

0.00000000000000

result:

ok found '0.000000000', expected '0.000000000', error '-0.000000000'

Test #24:

score: 0
Accepted
time: 170ms
memory: 17336kb

input:

1000000
- 102910932
+ 1000000000
+ 1000000000
+ 1000000000
+ 1000000000
+ 1000000000
+ 1000000000
- 722011197
- 427630036
+ 738303012
- 1
- 62996823
- 1
- 1
- 717325785
+ 1000000000
+ 253739553
+ 522925545
- 53263035
- 576267130
- 764198673
- 1
+ 149253463
- 93503980
+ 910579116
- 1
+ 1000000000
- 9...

output:

0.90457339747841

result:

ok found '0.904573397', expected '0.904573397', error '0.000000000'

Test #25:

score: 0
Accepted
time: 169ms
memory: 17272kb

input:

1000000
- 1000000000
- 1000000000
- 638521978
- 856740900
+ 328709862
+ 1
- 547643875
- 1000000000
+ 790604222
- 1000000000
- 868334780
- 231513670
+ 1
+ 185473938
+ 1
- 971111142
- 651862454
- 1000000000
+ 1
+ 579713318
+ 794684187
- 1000000000
- 1000000000
- 1000000000
- 716736759
+ 1
- 1000000000...

output:

0.07200141810382

result:

ok found '0.072001418', expected '0.072001418', error '0.000000000'

Test #26:

score: 0
Accepted
time: 123ms
memory: 8100kb

input:

1000000
+ 1000000000
- 1000000000
- 1000000000
- 1000000000
+ 1000000000
- 1000000000
- 1000000000
- 1000000000
- 1000000000
+ 1000000000
+ 1000000000
- 1000000000
+ 1000000000
- 1000000000
+ 1000000000
- 1000000000
- 1000000000
- 1000000000
- 1000000000
+ 1000000000
+ 1000000000
+ 1000000000
+ 1000...

output:

0.00000000000000

result:

ok found '0.000000000', expected '0.000000000', error '-0.000000000'

Test #27:

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

input:

100
+ 11
- 1
- 11
- 20
- 15
- 18
- 5
- 2
+ 7
+ 1
- 4
+ 18
- 6
- 1
+ 14
- 16
+ 19
- 18
- 18
- 7
+ 14
- 2
- 9
+ 7
- 5
+ 17
+ 9
- 4
- 11
+ 10
+ 6
- 14
- 19
+ 3
- 17
+ 3
+ 2
- 16
- 1
+ 8
- 15
- 12
- 6
+ 6
- 1
+ 7
- 1
- 14
+ 1
- 7
- 17
+ 14
+ 6
- 15
+ 14
+ 20
+ 8
+ 20
+ 17
+ 20
+ 18
- 6
- 12
- 5
+ 17
+ 1...

output:

0.51180472188876

result:

ok found '0.511804722', expected '0.511804722', error '0.000000000'

Test #28:

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

input:

1000
- 83
- 53
+ 26
- 8
- 57
- 5
- 26
+ 64
+ 52
- 61
+ 55
- 96
+ 67
+ 97
- 58
- 64
- 6
+ 81
+ 5
- 34
+ 23
+ 26
+ 46
+ 29
+ 56
+ 40
- 25
- 38
- 59
+ 45
+ 79
+ 50
- 67
- 45
- 21
+ 72
- 45
+ 26
- 2
+ 86
- 73
- 14
- 95
+ 33
- 92
- 84
+ 72
+ 86
- 18
- 7
+ 23
- 93
- 60
+ 4
- 13
+ 73
+ 82
+ 8
+ 64
- 1
- 25...

output:

0.51010792461290

result:

ok found '0.510107925', expected '0.510107925', error '0.000000000'

Test #29:

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

input:

567
+ 107
- 258
- 29
+ 157
+ 300
+ 26
+ 149
- 45
- 200
+ 96
- 235
- 107
- 293
- 165
+ 85
- 163
- 227
+ 181
+ 150
+ 134
- 35
+ 2
- 239
+ 203
- 191
+ 99
+ 170
+ 142
- 58
+ 116
+ 17
+ 82
- 267
+ 14
+ 182
- 208
+ 193
+ 256
- 289
- 278
+ 23
- 35
+ 48
- 117
+ 19
+ 93
- 70
- 158
- 33
- 116
+ 139
+ 81
+ 24
...

output:

0.49799501867995

result:

ok found '0.497995019', expected '0.497995019', error '0.000000000'

Test #30:

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

input:

666
+ 589
- 647
- 533
+ 632
+ 190
- 581
- 197
+ 61
- 625
- 225
- 244
- 15
+ 134
+ 362
- 288
+ 470
- 160
+ 641
+ 169
- 507
- 112
- 656
+ 243
+ 122
+ 495
+ 148
- 282
+ 568
+ 85
+ 544
- 307
+ 453
+ 261
- 465
- 9
+ 563
+ 621
- 285
+ 181
- 176
+ 359
+ 166
+ 408
+ 286
+ 36
+ 461
- 324
+ 492
- 561
- 158
+ ...

output:

0.54398701357262

result:

ok found '0.543987014', expected '0.543987014', error '0.000000000'

Test #31:

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

input:

1234
- 4300
+ 2279
+ 3371
- 295
+ 2929
+ 4315
- 2312
- 1611
- 509
- 416
- 2705
- 3280
- 1834
- 2612
+ 4044
- 4243
- 1611
+ 3282
+ 338
+ 2241
- 3203
+ 3162
- 1514
- 4172
- 908
+ 1809
+ 1196
+ 4069
+ 166
+ 1545
+ 420
- 1731
+ 2312
- 1475
- 2414
+ 1648
- 983
+ 2261
+ 2086
+ 800
- 3304
- 4113
- 3570
+ 2...

output:

0.51227901452566

result:

ok found '0.512279015', expected '0.512279015', error '0.000000000'

Test #32:

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

input:

7831
- 4856
- 6984
- 324
- 3410
- 1604
+ 7250
- 6187
+ 2072
- 4085
+ 2959
- 2705
+ 2598
- 7299
- 1701
+ 257
- 474
- 4139
+ 7208
+ 169
+ 2079
+ 2473
- 4761
- 3274
- 1877
- 5225
+ 1221
- 1212
+ 9079
+ 878
- 2719
+ 5046
+ 3773
- 1637
+ 4329
+ 5745
+ 1164
- 6296
- 967
+ 8651
+ 5003
- 5836
- 3172
+ 6556
...

output:

0.49804879671558

result:

ok found '0.498048797', expected '0.498048797', error '0.000000000'