QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#393607#5740. Testing Subjects Usually Diec20230201WA 1ms7980kbC++14942b2024-04-18 21:23:592024-04-18 21:24:00

Judging History

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

  • [2024-04-18 21:24:00]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:7980kb
  • [2024-04-18 21:23:59]
  • 提交

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;
    if(c==1) {
        cout<<n<<'\n';
        return 0;
    }
    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]);
    sum=0;
    for(int i=1;i<=n;i++) sum+=p2[i];
    t=(1+(n-1)*c)/sum;
    for(int i=1;i<=n;i++) {
        q[i]=(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) l=mid;
        else r=mid;
    }
    cout<<l<<'\n';
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

4 100
25 25 25 25

output:

4

result:

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

Test #2:

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

input:

2 0
1 4

output:

1.8

result:

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

Test #3:

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

input:

5 0
245 802 95 452 756

output:

4.46853

result:

ok found '4.4685300', expected '4.4685310', error '0.0000002'

Test #4:

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

input:

5 10
85 144 62 67 925

output:

3.08234

result:

ok found '3.0823400', expected '3.0823373', error '0.0000009'

Test #5:

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

input:

5 20
573 598 705 893 279

output:

4.66556

result:

ok found '4.6655600', expected '4.6655641', error '0.0000009'

Test #6:

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

input:

5 25
533 195 166 109 527

output:

3.93381

result:

ok found '3.9338100', expected '3.9338079', error '0.0000005'

Test #7:

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

input:

5 50
498 942 71 637 663

output:

2.98973

result:

wrong answer 1st numbers differ - expected: '3.8718857', found: '2.9897300', error = '0.2278362'