QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#36695 | #2440. Valentine's Day | claes | AC ✓ | 157ms | 3828kb | C++ | 680b | 2022-06-28 14:46:05 | 2022-06-28 14:46:07 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std ;
int n , t ;
double a[10010] ;
bool pd( double a , double b )
{
return a > b ;
}
int main ()
{
scanf( "%d" , &t ) ;
while( t -- )
{
scanf( "%d" , &n ) ;
double mx = 0 ;
for( int i = 0 ; i < n ; i ++ )
{
scanf( "%lf" , &a[i] ) ;
if( a[i] > mx ) mx = a[i] ;
}
sort( a , a + n , pd ) ;
double ans = a[0] ;
mx = a[0] ;
double mm = 0 ;
double tm , tx ;
for( int i = 1 ; i < n ; i ++ )
{
tx = ( 1 - mx - mm ) * a[i] + mx * ( 1 - a[i] ) ;
tm = mm + mx * a[i] ;
mx = tx ;
mm = tm ;
ans = max( ans , mx ) ;
}
printf( "%.12lf\n" , ans ) ;
}
return 0 ;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 157ms
memory: 3828kb
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