結果
問題 | No.2158 X日後に全完するhibit君 |
ユーザー | KowerKoint2010 |
提出日時 | 2022-12-01 10:36:33 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 351 ms / 2,000 ms |
コード長 | 1,743 bytes |
コンパイル時間 | 402 ms |
コンパイル使用メモリ | 82,788 KB |
実行使用メモリ | 77,696 KB |
最終ジャッジ日時 | 2024-10-08 10:34:23 |
合計ジャッジ時間 | 3,933 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 34 ms
51,968 KB |
testcase_01 | AC | 34 ms
52,352 KB |
testcase_02 | AC | 351 ms
77,696 KB |
testcase_03 | AC | 37 ms
52,480 KB |
testcase_04 | AC | 36 ms
52,224 KB |
testcase_05 | AC | 36 ms
52,096 KB |
testcase_06 | AC | 285 ms
77,300 KB |
testcase_07 | AC | 35 ms
52,224 KB |
testcase_08 | AC | 77 ms
76,652 KB |
testcase_09 | AC | 57 ms
71,552 KB |
testcase_10 | AC | 35 ms
51,968 KB |
testcase_11 | AC | 89 ms
76,540 KB |
testcase_12 | AC | 35 ms
52,608 KB |
testcase_13 | AC | 59 ms
69,760 KB |
testcase_14 | AC | 82 ms
76,488 KB |
testcase_15 | AC | 37 ms
52,480 KB |
testcase_16 | AC | 35 ms
52,352 KB |
testcase_17 | AC | 36 ms
52,480 KB |
testcase_18 | AC | 35 ms
52,096 KB |
testcase_19 | AC | 77 ms
76,160 KB |
testcase_20 | AC | 35 ms
52,224 KB |
testcase_21 | AC | 38 ms
52,480 KB |
testcase_22 | AC | 47 ms
62,720 KB |
testcase_23 | AC | 36 ms
52,224 KB |
testcase_24 | AC | 317 ms
77,528 KB |
testcase_25 | AC | 35 ms
52,352 KB |
testcase_26 | AC | 331 ms
77,548 KB |
testcase_27 | AC | 35 ms
52,224 KB |
ソースコード
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])