QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#619564 | #2440. Valentine's Day | Lavender_Field# | AC ✓ | 93ms | 3924kb | C++20 | 809b | 2024-10-07 14:40:21 | 2024-10-07 14:40:22 |
Judging History
answer
#include <algorithm>
#include <iomanip>
#include <iostream>
#include <queue>
template<typename T>
void upd_max(T &a, T b) { if (a < b) a = b; }
constexpr int N = 10000;
double P[N];
void solve()
{
int n; std::cin >> n;
for (int i = 0; i < n; ++i)
std::cin >> P[i];
std::sort(P, P + n, std::greater<>());
if (P[0] == 1)
{
std::cout << "1\n";
return;
}
double ans = 0;
double s = 0, p = 1;
for (int i = 0; i < n; ++i)
{
s += P[i] / (1 - P[i]), p *= 1 - P[i];
upd_max(ans, s * p);
}
std::cout << ans << "\n";
}
int main()
{
std::ios::sync_with_stdio(false), std::cin.tie(nullptr);
int T; std::cin >> T;
std::cout << std::fixed << std::setprecision(6);
while (T--) solve();
}
详细
Test #1:
score: 100
Accepted
time: 93ms
memory: 3924kb
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 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.375863 0...
result:
ok 100 numbers