QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#393612#5740. Testing Subjects Usually Diec20230201WA 1ms8092kbC++141.1kb2024-04-18 21:43:052024-04-18 21:43:06

Judging History

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

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

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;
    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<<l<<'\n';
    return 0;
}

詳細信息

Test #1:

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

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: 0ms
memory: 5932kb

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

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

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

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: 0ms
memory: 8056kb

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

input:

5 50
498 942 71 637 663

output:

3.87189

result:

wrong answer 1st numbers differ - expected: '3.8718857', found: '3.8718900', error = '0.0000011'