結果
| 問題 |
No.698 ペアでチームを作ろう
|
| ユーザー |
norioc
|
| 提出日時 | 2025-03-19 06:20:49 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 52 ms / 1,000 ms |
| コード長 | 429 bytes |
| コンパイル時間 | 397 ms |
| コンパイル使用メモリ | 82,668 KB |
| 実行使用メモリ | 64,100 KB |
| 最終ジャッジ日時 | 2025-03-19 06:20:52 |
| 合計ジャッジ時間 | 2,317 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 12 |
ソースコード
def bsf(x: int) -> int:
assert x != 0
return (x & -x).bit_length() - 1
N = int(input())
A = list(map(int, input().split()))
dp = [-1] * (1 << N)
dp[0] = 0
for i in range(1 << N):
if dp[i] == -1: continue
pi = bsf(~i)
for pj in range(pi+1, N):
if i & (1 << pj): continue
ni = i | (1 << pi) | (1 << pj)
dp[ni] = max(dp[ni], dp[i] + (A[pi] ^ A[pj]))
ans = dp[(1 << N) - 1]
print(ans)
norioc