結果
| 問題 |
No.2389 Cheating Code Golf
|
| コンテスト | |
| ユーザー |
👑 |
| 提出日時 | 2023-07-20 12:14:29 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 111 ms / 2,000 ms |
| コード長 | 789 bytes |
| コンパイル時間 | 312 ms |
| コンパイル使用メモリ | 81,984 KB |
| 実行使用メモリ | 76,472 KB |
| 最終ジャッジ日時 | 2024-09-20 08:47:38 |
| 合計ジャッジ時間 | 4,895 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 50 |
ソースコード
N, M = map(int, input().split())
ABP = [[1./v for v in map(int,input().split())] for _ in range(N)]
dp = [-float('inf')] * 4096
full_bit = (1 << N) - 1
for _ in range(M + 1):
ndp = dp.copy()
ndp[0] = 0.
for i in range(1, N + 1):
bi = (1 << i) - 1
while bi <= full_bit:
s = 0.
pi = bi
while pi > 0:
pbit = pi & -pi
pidx = (pbit - 1).bit_length()
dpi = bi ^ pbit
a, b, p = ABP[pidx]
s = max(s, ndp[dpi] + a, (ndp[dpi] + b) * p + dp[bi] * (1. - p))
pi &= pi - 1
ndp[bi] = max(ndp[bi], s)
x = bi & -bi
y = bi + x
bi = ((bi & ~y) >> x.bit_length()) | y
dp = ndp
print(dp[full_bit])