結果

問題 No.943 取り調べ
ユーザー rlangevinrlangevin
提出日時 2023-02-10 08:54:36
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 357 ms / 1,206 ms
コード長 655 bytes
コンパイル時間 303 ms
コンパイル使用メモリ 86,868 KB
実行使用メモリ 77,200 KB
最終ジャッジ日時 2023-09-21 12:04:05
合計ジャッジ時間 4,707 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 68 ms
71,156 KB
testcase_01 AC 67 ms
71,120 KB
testcase_02 AC 68 ms
71,552 KB
testcase_03 AC 68 ms
71,508 KB
testcase_04 AC 133 ms
77,112 KB
testcase_05 AC 357 ms
77,092 KB
testcase_06 AC 356 ms
76,832 KB
testcase_07 AC 68 ms
71,460 KB
testcase_08 AC 128 ms
76,964 KB
testcase_09 AC 108 ms
77,100 KB
testcase_10 AC 108 ms
77,172 KB
testcase_11 AC 97 ms
76,728 KB
testcase_12 AC 69 ms
71,252 KB
testcase_13 AC 81 ms
76,620 KB
testcase_14 AC 82 ms
76,508 KB
testcase_15 AC 72 ms
75,968 KB
testcase_16 AC 68 ms
71,268 KB
testcase_17 AC 103 ms
77,004 KB
testcase_18 AC 70 ms
71,160 KB
testcase_19 AC 76 ms
76,428 KB
testcase_20 AC 72 ms
75,840 KB
testcase_21 AC 69 ms
71,424 KB
testcase_22 AC 98 ms
76,532 KB
testcase_23 AC 188 ms
77,200 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N = int(input())
X = []
for i in range(N):
    x = list(map(int, input().split()))
    now = 0
    for j in range(N):
        now += x[j] * (1 << j)
    X.append(now)

A = list(map(int, input().split()))
ans = 10 ** 18
N2 = 1 << N
for s in range(N2):
    now = s
    for i in range(N):
        pre = now
        for j in range(N):
            if (now >> j) & 1:
                continue
            if X[j] == (now & X[j]):
                now += 1 << j
        if pre == now:
            break
    if now == (1 << N) - 1:
        v = 0
        for i in range(N):
            if (s >> i) & 1:
                v += A[i]
        ans = min(ans, v)
print(ans)
0