QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#619494 | #2440. Valentine's Day | WorldFinalEscaped# | AC ✓ | 74ms | 3988kb | C++14 | 711b | 2024-10-07 14:25:48 | 2024-10-07 14:25:49 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
double pre[10005],suf[10005];
double a[10005];int n;
int main(){
int T;scanf("%d",&T);
while(T--){
int n;scanf("%d",&n);
for(int i=1;i<=n;i++){
scanf("%lf",&a[i]);
}
sort(a+1,a+n+1);
// reverse(a+1,a+n+1);
if(a[n]>=0.5000)
printf("%.10f\n",a[n]);
else{
double ans=a[n],cur=1-a[n];
for(int i=n-1;i>=1;i--){
double newans=ans*(1-a[i])+a[i]*cur;
if(newans>ans)ans=newans;
else break;
cur*=1-a[i];
}
printf("%.10f\n",ans);
}
}
}
详细
Test #1:
score: 100
Accepted
time: 74ms
memory: 3988kb
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