/* slightly faster; ignores some states */ #include #include using namespace std ; const int MAXN = 17 ; const int MAXT = 100 ; double dp[MAXT+1][1LL<> n >> maxtime ; for (int i=0; i> r[i] >> s[i] >> p[i] ; for (int i=0; i 0) { if (r[i] + s[i] <= maxtime) { dp[r[i]+s[i]][1<>n)==0; bm++) { if (dp[t][bm] == 0) continue ; double subd = 0 ; int unreadsolved = 0 ; int read = 0 ; for (int i=0; i> i) & 1) { read++ ; subd += solved[i] ; } else if (solved[i] != 0) { unreadsolved++ ; } } double psum = dp[t][bm] ; for (int i=0; i> i) & 1) continue ; for (int dosolve=0; dosolve<2; dosolve++) { double pm = (dosolve ? p[i] : 1-p[i]) ; if (pm == 0) continue ; int t2 = t + r[i] + (dosolve ? s[i] : 0) ; if (t2 > maxtime) continue ; double vv = 0 ; if (unreadsolved) vv = psum * pm * solved[i] / (totsolves - subd) ; else vv = psum * pm / (n - read) ; dp[t2][bm|(1<