QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#619136#2440. Valentine's DayCheek_support#AC ✓92ms4052kbC++20529b2024-10-07 13:14:352024-10-07 13:14:36

Judging History

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

  • [2024-10-07 13:14:36]
  • 评测
  • 测评结果:AC
  • 用时:92ms
  • 内存:4052kb
  • [2024-10-07 13:14:35]
  • 提交

answer

#include <bits/stdc++.h>
#define ll long long
#define ld long double
using namespace std;
const int N=100100;
ld a[N];
int main(){
    int _t;
    scanf("%d",&_t);
    for(;_t;_t--){
        int n;
        scanf("%d",&n);
        for(int i=1;i<=n;i++)
            scanf("%Lf",&a[i]);
        sort(a+1,a+n+1);
        ld A=1,B=0;
        for(int i=n;i>=1;i--){
            if(B>A)break;
            B=A*a[i]+B*(1.0-a[i]);
            A=A*(1-a[i]);
        }
        printf("%Lf\n",B);
    }
    return 0;
}

详细

Test #1:

score: 100
Accepted
time: 92ms
memory: 4052kb

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.398190
0.373684
0.410885
0.421374
0.419873
0.421062
0.420797
0.419891
0.419860
0.000100
0.000000
0.003341
0.003336
0.001427
0.003169
0.029231
0.061862
0.022757
0.015698
0.035934
1.000000
0.376079
0.376081
0.376081
0.376082
0.376080
0.376077
0.376083
0.376078
0.376084
0.376073
0.376079
0.375987
0.3...

result:

ok 100 numbers