結果

問題 No.943 取り調べ
ユーザー TakoKurage
提出日時 2019-12-16 11:09:59
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 505 bytes
コンパイル時間 148 ms
コンパイル使用メモリ 82,240 KB
実行使用メモリ 77,992 KB
最終ジャッジ日時 2024-07-02 19:39:31
合計ジャッジ時間 4,370 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 18 WA * 6
権限があれば一括ダウンロードができます

ソースコード

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 i, x in enumerate(X):
        if state & x == x:
            state |= 1 << i

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

    if state != complete:
        continue

    ans = min(ans, cand)

print(ans)
0