結果

問題 No.698 ペアでチームを作ろう
ユーザー otsuneko
提出日時 2024-07-19 00:11:09
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 141 ms / 1,000 ms
コード長 301 bytes
コンパイル時間 264 ms
コンパイル使用メモリ 82,112 KB
実行使用メモリ 76,396 KB
最終ジャッジ日時 2024-07-19 00:11:12
合計ジャッジ時間 2,505 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 12
権限があれば一括ダウンロードができます

ソースコード

diff #

import itertools
N = int(input())
A = list(map(int,input().split()))

dp = [0]*(1<<N)

for s in range(1<<N):
    for i,j in itertools.combinations(range(N),2):
        if not s&(1<<i) and not s&(1<<j):
            dp[s|(1<<i)|(1<<j)] = max(dp[s|(1<<i)|(1<<j)], dp[s]+(A[i]^A[j]))

print(dp[(1<<N)-1])
0