結果

問題 No.698 ペアでチームを作ろう
ユーザー ntuda
提出日時 2024-10-20 16:54:35
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 654 ms / 1,000 ms
コード長 492 bytes
コンパイル時間 435 ms
コンパイル使用メモリ 82,440 KB
実行使用メモリ 77,440 KB
最終ジャッジ日時 2024-10-20 16:54:43
合計ジャッジ時間 7,649 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 12
権限があれば一括ダウンロードができます

ソースコード

diff #

def dfs(x):
    global ans, sum0
    if x == 0:
        ans = max(ans, sum0)
        return
    a = NU.index(True)
    NU[a] = False
    for b in range(a + 1,N):
        if True not in NU[b:]:
            continue
        c = NU[b:].index(True) + b
        NU[c] = False
        sum0 += A[a] ^ A[c]
        dfs(x - 1)
        sum0 -= A[a] ^ A[c]
        NU[c] = True
    NU[a] = True

N = int(input())
A = list(map(int, input().split()))
NU = [True] * N
ans = 0
sum0 = 0
dfs(N//2)
print(ans)
0