結果

問題 No.943 取り調べ
ユーザー りあんりあん
提出日時 2019-12-05 22:17:54
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 195 ms / 1,206 ms
コード長 325 bytes
コンパイル時間 367 ms
コンパイル使用メモリ 87,128 KB
実行使用メモリ 79,236 KB
最終ジャッジ日時 2023-08-24 17:19:28
合計ジャッジ時間 4,261 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 83 ms
71,152 KB
testcase_01 AC 81 ms
71,100 KB
testcase_02 AC 84 ms
71,148 KB
testcase_03 AC 79 ms
71,468 KB
testcase_04 AC 171 ms
79,236 KB
testcase_05 AC 195 ms
78,856 KB
testcase_06 AC 192 ms
78,984 KB
testcase_07 AC 80 ms
71,220 KB
testcase_08 AC 171 ms
78,764 KB
testcase_09 AC 110 ms
76,896 KB
testcase_10 AC 112 ms
76,856 KB
testcase_11 AC 98 ms
76,764 KB
testcase_12 AC 81 ms
71,276 KB
testcase_13 AC 87 ms
76,296 KB
testcase_14 AC 89 ms
76,452 KB
testcase_15 AC 80 ms
71,428 KB
testcase_16 AC 79 ms
71,056 KB
testcase_17 AC 110 ms
77,080 KB
testcase_18 AC 81 ms
71,312 KB
testcase_19 AC 87 ms
76,400 KB
testcase_20 AC 83 ms
71,228 KB
testcase_21 AC 82 ms
71,052 KB
testcase_22 AC 108 ms
77,092 KB
testcase_23 AC 181 ms
78,984 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n = int(input())
b = [ int(''.join(list(reversed(input().replace(" ", "")))), 2) for i in range(n) ]
a = list(map(int, input().split()))
dp = [1 << 28] * (1 << n)
dp[0] = 0
for i in range(1 << n):
    for j in range(n):
        dp[i | 1 << j] = min(dp[i | 1 << j], dp[i] + (0 if (i & b[j]) == b[j] else a[j]))

print(dp[-1])
0