QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#619196 | #2440. Valentine's Day | IllusionaryDominance# | AC ✓ | 87ms | 3912kb | C++20 | 566b | 2024-10-07 13:29:33 | 2024-10-07 13:29:33 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
int main()
{
ios::sync_with_stdio(false);
cin.tie(0); cout.tie(0);
int T; cin >> T;
while(T--)
{
int n;
cin >> n;
vector<double> a(n), f(n), g(n);
for(auto &x : a) cin >> x;
sort(a.begin(), a.end());
f[n-1] = a[n-1]; g[n-1] = 1-f[n-1];
for(int i=n-2;i>=0;--i)
{
f[i]=(1-a[i])*f[i+1]+a[i]*g[i+1];
g[i]=(1-a[i])*g[i+1];
}
cout << fixed << setprecision(10) << *max_element(f.begin(), f.end()) << "\n";
}
}
详细
Test #1:
score: 100
Accepted
time: 87ms
memory: 3912kb
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