QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#619341#2440. Valentine's Dayurayaha_yahaura#AC ✓94ms3984kbC++14641b2024-10-07 13:55:102024-10-07 13:55:11

Judging History

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

  • [2024-10-07 13:55:11]
  • 评测
  • 测评结果:AC
  • 用时:94ms
  • 内存:3984kb
  • [2024-10-07 13:55:10]
  • 提交

answer

#include<iostream>
#include<algorithm>
#include<iomanip>
using namespace std;
int T,n;
double p[10005],pro,ans,cur;
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    int i;
    cin>>T;
    while(T--){
        cin>>n;
        for(i=1;i<=n;i++)
            cin>>p[i];
        sort(p+1,p+n+1,[](double a,double b){return a>b;});
        ans=cur=p[1];
        pro=1-p[1];
        for(i=2;i<=n;i++){
            cur*=(1-p[i]);
            cur+=pro*p[i];
            pro*=(1-p[i]);
            ans=max(ans,cur);
        }
        cout<<fixed<<setprecision(10)<<ans<<'\n';
    }
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 94ms
memory: 3984kb

input:

100
10
0.020874 0.180969 0.015588 0.043033 0.181293 0.033025 0.163341 0.104341 0.065442 0.129546
10
0.019357 0.210598 0.045487 0.051145 0.014579 0.135566 0.004401 0.008004 0.106695 0.056974
10
0.062679 0.216144 0.010137 0.031823 0.233062 0.042464 0.099544 0.140483 0.201337 0.045349
100
0.116404 0.19...

output:

0.3981900715
0.3736838865
0.4108853628
0.4213740444
0.4198729710
0.4210622570
0.4207968580
0.4198908976
0.4198603932
0.0000999901
0.0000000000
0.0033410000
0.0033360000
0.0014270033
0.0031690000
0.0292312530
0.0618624313
0.0227574836
0.0156984969
0.0359344799
1.0000000000
0.3760790137
0.3760806761
0...

result:

ok 100 numbers