QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#393615#5740. Testing Subjects Usually Diec20230201WA 1ms3984kbC++141.3kb2024-04-18 21:48:042024-04-18 21:48:05

Judging History

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

  • [2024-04-18 21:48:05]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3984kb
  • [2024-04-18 21:48:04]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;

typedef long double db;

const db eps=1e-8;
const int maxn=1e5+5;

int n; db c;

db p[maxn], q[maxn], p2[maxn];

db check(db s) {
    db res=0;
    for(int i=1;i<=n;i++) res+= p[i]*(1+(1-q[i])*c*s)/(1-(1-q[i])*(1-c));
    return res;    
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);
    cin>>n>>c;
    c/=100;
    db sum=0, t;
    for(int i=1;i<=n;i++) cin>>p[i], sum+=p[i];
    for(int i=1;i<=n;i++) p[i]/=sum, p2[i]=sqrt(p[i]);
    if(c==1) {
        db mn=1e9;
        for(int i=1;i<=n;i++) mn=min(mn,p[i]);
        cout<<fixed<<setprecision(10)<<(db)1/mn<<'\n';
        return 0;
    }
    sum=0;
    for(int i=1;i<=n;i++) sum+=p2[i];
    t=(1+(n-1)*c)/sum;
    db lt=0, rt=t;
    while(rt-lt>eps) {
        db mid=(lt+rt)*0.5, res=0;
        for(int i=1;i<=n;i++) res+= q[i]=max((db)0,(p2[i]*mid-c)/(1-c));
        if(res<=1) lt=mid;
        else rt=mid;
    }
    t=lt;
    for(int i=1;i<=n;i++) q[i]=max((db)0,(p2[i]*t-c)/(1-c));
    db l=0, r=1e9;
    while(r-l>eps) {
        db mid=(l+r)*0.5;
        db res=check(mid);
        if(check(mid)<=mid) r=mid;
        else l=mid;
    }
    cout<<fixed<<setprecision(10)<<l<<'\n';
    return 0;
}

详细

Test #1:

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

input:

4 100
25 25 25 25

output:

4.0000000000

result:

ok found '4.0000000', expected '4.0000000', error '0.0000000'

Test #2:

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

input:

2 0
1 4

output:

1.8000000102

result:

ok found '1.8000000', expected '1.8000000', error '0.0000000'

Test #3:

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

input:

5 0
245 802 95 452 756

output:

4.4685310591

result:

ok found '4.4685311', expected '4.4685310', error '0.0000000'

Test #4:

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

input:

5 10
85 144 62 67 925

output:

3.0823373576

result:

ok found '3.0823374', expected '3.0823373', error '0.0000000'

Test #5:

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

input:

5 20
573 598 705 893 279

output:

4.6655641434

result:

ok found '4.6655641', expected '4.6655641', error '0.0000000'

Test #6:

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

input:

5 25
533 195 166 109 527

output:

3.9338079946

result:

ok found '3.9338080', expected '3.9338079', error '0.0000000'

Test #7:

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

input:

5 50
498 942 71 637 663

output:

3.8718857634

result:

ok found '3.8718858', expected '3.8718857', error '0.0000000'

Test #8:

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

input:

5 75
971 663 827 333 382

output:

3.7488898999

result:

ok found '3.7488899', expected '3.7488899', error '0.0000000'

Test #9:

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

input:

5 90
736 303 722 239 696

output:

3.7688207416

result:

ok found '3.7688207', expected '3.7688203', error '0.0000001'

Test #10:

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

input:

100 3
658 202 750 953 273 250 658 749 723 227 147 300 891 268 626 9 436 76 199 550 256 668 646 520 736 830 147 712 696 56 668 685 705 170 384 262 264 645 453 806 436 145 575 485 77 871 716 408 536 245 952 385 469 776 647 262 951 784 314 270 122 969 179 635 513 444 709 576 887 834 131 422 334 978 875...

output:

76.0238827377

result:

ok found '76.0238827', expected '76.0238806', error '0.0000000'

Test #11:

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

input:

100 7
732 702 802 720 694 714 45 298 555 362 471 319 538 926 146 669 947 210 436 4 652 273 408 91 25 626 687 586 747 415 823 623 364 487 26 256 149 606 458 173 254 99 191 44 829 789 17 894 353 597 809 880 651 126 465 288 369 544 136 703 805 231 305 81 680 753 592 293 374 273 504 884 257 480 588 819 ...

output:

68.6886438353

result:

ok found '68.6886438', expected '68.6886435', error '0.0000000'

Test #12:

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

input:

100 93
769 488 41 386 28 822 145 782 981 94 665 928 187 344 956 992 367 530 899 499 292 151 791 309 21 35 756 41 592 65 788 914 497 961 69 170 535 586 853 192 497 346 8 723 71 838 545 628 806 937 128 436 310 917 956 490 483 984 799 865 116 643 803 301 407 358 187 699 128 271 444 887 904 22 556 301 9...

output:

51.1578107654

result:

ok found '51.1578108', expected '51.1578082', error '0.0000001'

Test #13:

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

input:

100 99
725 12 862 184 81 723 289 915 414 919 360 251 232 295 807 305 968 480 324 666 87 348 117 25 51 447 976 795 598 372 153 661 949 409 974 911 915 801 569 138 682 431 604 172 249 50 890 337 471 828 451 856 627 349 247 487 649 223 882 48 470 177 556 258 744 930 101 763 817 332 54 187 707 521 989 5...

output:

51.3845865857

result:

ok found '51.3845866', expected '51.3845849', error '0.0000000'

Test #14:

score: -100
Wrong Answer
time: 1ms
memory: 3984kb

input:

100 100
532 836 32 963 414 408 831 402 576 222 72 344 242 723 191 935 946 78 364 548 702 486 549 801 659 734 380 776 800 458 146 772 656 979 849 148 283 106 728 506 295 58 873 927 471 416 649 662 279 990 437 554 644 733 542 686 915 478 787 209 504 522 646 309 266 66 214 592 290 563 262 524 434 655 1...

output:

2037.8000000000

result:

wrong answer 1st numbers differ - expected: '51.4596000', found: '2037.8000000', error = '38.5999969'