結果
問題 |
No.943 取り調べ
|
ユーザー |
![]() |
提出日時 | 2020-02-02 21:12:00 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
TLE
|
実行時間 | - |
コード長 | 667 bytes |
コンパイル時間 | 143 ms |
コンパイル使用メモリ | 12,672 KB |
実行使用メモリ | 17,564 KB |
最終ジャッジ日時 | 2024-09-18 21:25:18 |
合計ジャッジ時間 | 3,275 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 6 TLE * 3 -- * 15 |
ソースコード
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)