結果
| 問題 | 
                            No.698 ペアでチームを作ろう
                             | 
                    
| ユーザー | 
                             | 
                    
| 提出日時 | 2022-01-28 11:50:28 | 
| 言語 | PyPy3  (7.3.15)  | 
                    
| 結果 | 
                             
                                AC
                                 
                             
                            
                         | 
                    
| 実行時間 | 123 ms / 1,000 ms | 
| コード長 | 441 bytes | 
| コンパイル時間 | 379 ms | 
| コンパイル使用メモリ | 81,920 KB | 
| 実行使用メモリ | 76,032 KB | 
| 最終ジャッジ日時 | 2024-12-28 08:24:10 | 
| 合計ジャッジ時間 | 2,519 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge3 / judge4 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 12 | 
ソースコード
N = int(input())
A = list(map(int, input().split()))
def dfs(tot, used):
    if used == (1 << N) - 1:
        return tot
    res = 0
    for i in range(N):
        if used >> i & 1:
            continue
        for j in range(i + 1, N):
            if used >> j & 1:
                continue
            tmp = dfs(tot + (A[i] ^ A[j]), used | 1 << i | 1 << j)
            res = max(res, tmp)
        break
    return res
print(dfs(0, 0))