結果

問題 No.2158 X日後に全完するhibit君
ユーザー KowerKoint2010KowerKoint2010
提出日時 2022-12-01 10:36:33
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 332 ms / 2,000 ms
コード長 1,743 bytes
コンパイル時間 269 ms
コンパイル使用メモリ 82,048 KB
実行使用メモリ 77,568 KB
最終ジャッジ日時 2024-04-17 01:46:10
合計ジャッジ時間 3,485 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 33 ms
52,352 KB
testcase_01 AC 34 ms
51,968 KB
testcase_02 AC 332 ms
77,568 KB
testcase_03 AC 34 ms
52,452 KB
testcase_04 AC 34 ms
52,352 KB
testcase_05 AC 34 ms
51,968 KB
testcase_06 AC 277 ms
77,100 KB
testcase_07 AC 35 ms
52,224 KB
testcase_08 AC 72 ms
76,416 KB
testcase_09 AC 58 ms
71,936 KB
testcase_10 AC 33 ms
52,736 KB
testcase_11 AC 82 ms
76,544 KB
testcase_12 AC 34 ms
52,224 KB
testcase_13 AC 56 ms
69,376 KB
testcase_14 AC 74 ms
76,672 KB
testcase_15 AC 35 ms
52,096 KB
testcase_16 AC 36 ms
52,096 KB
testcase_17 AC 36 ms
52,268 KB
testcase_18 AC 35 ms
52,480 KB
testcase_19 AC 74 ms
76,152 KB
testcase_20 AC 38 ms
52,352 KB
testcase_21 AC 35 ms
52,224 KB
testcase_22 AC 44 ms
62,464 KB
testcase_23 AC 32 ms
52,608 KB
testcase_24 AC 288 ms
77,312 KB
testcase_25 AC 36 ms
52,352 KB
testcase_26 AC 300 ms
77,312 KB
testcase_27 AC 36 ms
52,224 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n, k = map(int, input().split())
p = []
s = []
t = []
for _ in range(n):
    pi, si, ti = map(int, input().split())
    p.append(pi)
    s.append(si)
    t.append(ti)
prodp = [1]
for i in range(n):
    prodp.append(prodp[-1] * (p[i] + 1))
def idx_encode(data):
    idx = 0
    for i in range(n):
        idx *= p[i] + 1
        idx += data[i]
    return idx
def idx_decode(idx):
    data = []
    for i in range(n - 1, -1, -1):
        data.append(idx % (p[i] + 1))
        idx //= p[i] + 1
    data.reverse()
    return data
winable = False
win = [False] * (1 << n)
for i in range(1 << n):
    tmp = 0
    for j in range(n):
        if i >> j & 1:
            tmp += t[j]
        else:
            tmp += s[j]
    if tmp <= 60:
        win[i] = True
        winable = True
if not winable:
    print(-1)
    exit()
mx = [0] * prodp[n]
mn = [10**9] * prodp[n]
ex = [0.] * prodp[n]
for i in range(prodp[n]-1, -1, -1):
    data = idx_decode(i)
    numcases = 0
    numselfcases = 0
    sumsteps = 0.
    for j in range(1 << n):
        cases = 1
        ndata = data.copy()
        for l in range(n):
            if j >> l & 1:
                cases *= max(0, data[l] - k)
            else:
                cases *= p[l] - data[l]
                ndata[l] += 1
        if cases == 0:
            continue
        ni = idx_encode(ndata)
        numcases += cases
        sumsteps += cases
        if win[j]:
            mn[i] = min(mn[i], 1)
            mx[i] = max(mx[i], 1)
        elif ni == i:
            numselfcases += cases
        else:
            sumsteps += cases * ex[ni]
            mn[i] = min(mn[i], mn[ni] + 1)
            mx[i] = max(mx[i], mx[ni] + 1)
    ex[i] = sumsteps / (numcases - numselfcases)
print(mn[0], mx[0], ex[0])
0