結果

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

ソースコード

diff #

def search(x):
    j = 0
    for i in range(N):
        if NU[i] == True:
            if j == x:
                return i
            j += 1

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