結果
| 問題 | No.943 取り調べ |
| コンテスト | |
| ユーザー |
r_ishida
|
| 提出日時 | 2020-02-02 21:12:27 |
| 言語 | PyPy3 (7.3.23) |
| 結果 |
AC
|
| 実行時間 | 146 ms / 1,206 ms |
| + 414µs | |
| コード長 | 667 bytes |
| 記録 | |
| コンパイル時間 | 238 ms |
| コンパイル使用メモリ | 95,976 KB |
| 実行使用メモリ | 84,480 KB |
| 最終ジャッジ日時 | 2026-08-30 11:56:33 |
| 合計ジャッジ時間 | 3,680 ms |
|
ジャッジサーバーID (参考情報) |
judge2_0 / judge3_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 24 |
ソースコード
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)
r_ishida