結果

問題 No.943 取り調べ
ユーザー r_ishidar_ishida
提出日時 2020-02-02 21:12:00
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
TLE  
実行時間 -
コード長 667 bytes
コンパイル時間 85 ms
コンパイル使用メモリ 11,936 KB
実行使用メモリ 14,572 KB
最終ジャッジ日時 2023-10-19 01:27:13
合計ジャッジ時間 8,290 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 31 ms
10,084 KB
testcase_01 AC 30 ms
10,084 KB
testcase_02 AC 33 ms
10,084 KB
testcase_03 AC 29 ms
10,084 KB
testcase_04 TLE -
testcase_05 AC 1,128 ms
10,248 KB
testcase_06 AC 1,158 ms
10,248 KB
testcase_07 AC 30 ms
10,084 KB
testcase_08 TLE -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

n = int(input())
x = []
y = []
for i in range(n):
    tmp = list(map(int, input().split()))
    y.append(tmp)
    tmp2 = 0
    for j in range(n):
        tmp2 += y[i][j] * 2 ** j
    x.append(tmp2)
a = list(map(int, input().split()))

ans = sum(a)

for i in range(2 ** n):
    tmp = 0
    for j in range(n):
        tmp += a[j] if ((i >> j) & 1) == 1 else 0
    if tmp >= ans:
        continue
    l = i
    c = 0
    k = -1
    while k + 1 < n:
        k += 1
        if ((c >> k) & 1) == 1:
            continue
        if (l & x[k]) == x[k]:
            c |= 1 << k
            l |= 1 << k
            k = -1

    if c == (1 << n) - 1:
        ans = tmp
print(ans)
0