結果

問題 No.943 取り調べ
ユーザー TakoKurageTakoKurage
提出日時 2019-12-16 11:20:01
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 827 ms / 1,206 ms
コード長 440 bytes
コンパイル時間 336 ms
コンパイル使用メモリ 86,912 KB
実行使用メモリ 79,092 KB
最終ジャッジ日時 2023-09-15 17:32:41
合計ジャッジ時間 7,656 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 74 ms
71,240 KB
testcase_01 AC 74 ms
71,376 KB
testcase_02 AC 72 ms
71,256 KB
testcase_03 AC 73 ms
71,428 KB
testcase_04 AC 580 ms
78,672 KB
testcase_05 AC 715 ms
77,968 KB
testcase_06 AC 714 ms
78,072 KB
testcase_07 AC 75 ms
71,540 KB
testcase_08 AC 580 ms
78,516 KB
testcase_09 AC 288 ms
78,516 KB
testcase_10 AC 255 ms
78,012 KB
testcase_11 AC 196 ms
78,512 KB
testcase_12 AC 73 ms
71,244 KB
testcase_13 AC 98 ms
76,860 KB
testcase_14 AC 112 ms
78,216 KB
testcase_15 AC 81 ms
76,348 KB
testcase_16 AC 74 ms
71,576 KB
testcase_17 AC 282 ms
78,136 KB
testcase_18 AC 78 ms
76,060 KB
testcase_19 AC 104 ms
77,436 KB
testcase_20 AC 83 ms
76,276 KB
testcase_21 AC 73 ms
71,404 KB
testcase_22 AC 289 ms
78,708 KB
testcase_23 AC 827 ms
79,092 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N = int(input())
X = [int(input().replace(" ", "")[::-1], 2) for _ in range(N)]
A = [int(i) for i in input().split()]

complete = 2 ** N - 1

ans = float("inf")
for state in range(2 ** N):

    cand = sum(a for i, a in enumerate(A) if state >> i & 1)

    for _ in range(N):
        for i, x in enumerate(X):
            if state & x == x:
                state |= 1 << i

    if state == complete:
        ans = min(ans, cand)

print(ans)
0