QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#619211 | #2440. Valentine's Day | untitledtwo# | AC ✓ | 70ms | 3972kb | C++17 | 474b | 2024-10-07 13:30:53 | 2024-10-07 13:30:54 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
double a[10010];
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, greater<double>());
double ans = a[1], prod = 1 - a[1];
for(int i = 2; i <= n; i++)
{
if(prod - ans < 0)
break;
ans += a[i] * (prod - ans);
prod *= (1 - a[i]);
}
printf("%.12lf\n", ans);
}
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 70ms
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.398190071489 0.373683886459 0.410885362758 0.421374044378 0.419872971016 0.421062257019 0.420796858020 0.419890897576 0.419860393202 0.000099990100 0.000000000000 0.003341000000 0.003336000000 0.001427003306 0.003169000000 0.029231252961 0.061862431346 0.022757483568 0.015698496871 0.035934479901 ...
result:
ok 100 numbers