結果

問題 No.698 ペアでチームを作ろう
ユーザー flippergo
提出日時 2024-10-13 12:48:48
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 239 ms / 1,000 ms
コード長 477 bytes
コンパイル時間 238 ms
コンパイル使用メモリ 82,300 KB
実行使用メモリ 79,016 KB
最終ジャッジ日時 2024-10-13 12:48:52
合計ジャッジ時間 3,470 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 12
権限があれば一括ダウンロードができます

ソースコード

diff #

from itertools import combinations
N = int(input())
A = list(map(int,input().split()))
dp = {}
for z in combinations(range(N),2):
    dp[z] = A[z[0]]^A[z[1]]
for n in range(4,N+1,2):
    for z in combinations(range(N),n):
        dp[z] = 0
        for y in combinations(z,2):
            z1 = list(z)
            z1.remove(y[0])
            z1.remove(y[1])
            z1 = tuple(z1)
            dp[z] = max(dp[z],dp[z1]+(A[y[0]]^A[y[1]]))
ans = tuple(range(N))
print(dp[ans])
0