#include #include #include #include using namespace std ; using ll = long long ; int n ; vector pi ; vector sn ; const int MAX = 256 ; double a[MAX][MAX], b[MAX][MAX] ; vector stationary(int n, double p) { for (int i=0; i r(n) ; for (int i=0; i> n ; cout << setprecision(15) ; pi.resize(n) ; sn.resize(n) ; for (auto &v: pi) cin >> v ; for (auto &v: sn) cin >> v ; vector>> steps(n) ; for (int i=0; i hi(1LL<>n)==0; mask++) { double hip = hi[mask] ; int stage = __builtin_popcount(mask) ; int los = sn[stage] ; int his = sn[stage] ; if (stage > 0) { los -= sn[stage-1] ; his += sn[stage-1] ; } for (ll b=0; b> b) & 1) == 0) { double p = hip * steps[b][stage][his] + (1-hip) * steps[b][stage][los] ; hi[mask | (1LL << b)] = max(hi[mask | (1LL << b)], p) ; } } cout << hi[(1LL << n) - 1] << endl ; }