結果

問題 No.698 ペアでチームを作ろう
ユーザー rin204
提出日時 2022-03-23 16:03:17
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 111 ms / 1,000 ms
コード長 474 bytes
コンパイル時間 243 ms
コンパイル使用メモリ 82,324 KB
実行使用メモリ 76,288 KB
最終ジャッジ日時 2024-10-11 18:59:15
合計ジャッジ時間 2,471 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 12
権限があれば一括ダウンロードができます

ソースコード

diff #

n = int(input())
A = list(map(int, input().split()))
used = [False] * n

def dfs(i, x):
    if 2 * i == n:
        return x
    
    for j in range(n):
        if not used[j]:
            used[j] = True
            a = A[j]
            break
    ret = 0
    for k in range(j + 1, n):
        if not used[k]:
            used[k] = True
            ret = max(ret, dfs(i + 1, x + (a ^ A[k])))
            used[k] = False
    used[j] = False
    return ret
    
print(dfs(0, 0))
0