QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#619213 | #2440. Valentine's Day | AnotherDayofSun# | AC ✓ | 75ms | 3972kb | C++20 | 801b | 2024-10-07 13:31:43 | 2024-10-07 13:31:46 |
Judging History
answer
#include<bits/stdc++.h>
#define N 100005
#define re
#define ll long long
using namespace std;
int n,m,K,q,T;
inline void Rd(int &res){
re char c;res=0;
while(c=getchar(),c<48);
do res=(res<<3)+(res<<1)+(c^48);
while(c=getchar(),c>47);
}
double p[N];
int main(){
Rd(T);
while(T--){
Rd(n);
for(int i=1;i<=n;i++)scanf("%lf",&p[i]);
sort(p+1,p+n+1);
if(p[n]>0.5-(1e-8)){
printf("%.10lf\n",p[n]);
continue;
}
double p0=1.0,p1=0.0;
for(int i=n;i>=1;i--){
double p01=p0*(1.0-p[i]);
double p11=p1*(1.0-p[i]) + p0*p[i] ;
if(p11>p1)p1=p11,p0=p01;
}
printf("%.10lf\n",p1);
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 75ms
memory: 3972kb
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