結果
| 問題 | No.698 ペアでチームを作ろう |
| ユーザー |
norioc
|
| 提出日時 | 2025-03-19 06:20:49 |
| 言語 | PyPy3 (7.3.17) |
| 結果 |
AC
|
| 実行時間 | 72 ms / 1,000 ms |
| コード長 | 429 bytes |
| 記録 | |
| コンパイル時間 | 441 ms |
| コンパイル使用メモリ | 96,200 KB |
| 実行使用メモリ | 84,352 KB |
| 最終ジャッジ日時 | 2026-07-07 06:26:40 |
| 合計ジャッジ時間 | 2,522 ms |
|
ジャッジサーバーID (参考情報) |
judge3_0 / judge2_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| 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