QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#619200 | #2440. Valentine's Day | Afterlife# | AC ✓ | 65ms | 4112kb | C++20 | 630b | 2024-10-07 13:29:58 | 2024-10-07 13:29:59 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
int n;
double a[10005];
void solv() {
cin >> n;
for(int i = 1;i <= n;i++) {
string s;cin >> s;
a[i] = stod(s) ;
}
sort(a + 1 , a + n + 1);
double ans = a[n] ;
double prod = 1;
double s = 0;
for(int i = n;i >= 1;i--) {
s = s * (1 - a[i]) + a[i] * prod ;
prod *= (1 - a[i]);
ans = max(ans , s);
}
cout << fixed << setprecision(15) << ans << '\n';
}
int main() {
ios::sync_with_stdio(false) ; cin.tie(0) ;
int t; //scanf("%d",&t) ;
cin >> t;
while(t--) solv() ;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 65ms
memory: 4112kb
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.398190071488907 0.373683886459076 0.410885362758500 0.421374044378281 0.419872971015697 0.421062257018857 0.420796858020452 0.419890897575728 0.419860393202155 0.000099990100485 0.000000000000000 0.003341000000000 0.003336000000000 0.001427003306000 0.003169000000000 0.029231252961392 0.0618624313...
result:
ok 100 numbers