結果

問題 No.699 ペアでチームを作ろう2
ユーザー rlangevinrlangevin
提出日時 2023-02-03 00:01:50
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 850 ms / 1,000 ms
コード長 568 bytes
コンパイル時間 301 ms
コンパイル使用メモリ 82,116 KB
実行使用メモリ 76,508 KB
最終ジャッジ日時 2024-07-02 09:48:26
合計ジャッジ時間 9,680 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 12
権限があれば一括ダウンロードができます

ソースコード

diff #

from itertools import *

def popcount(n):
    cnt = 0
    while n:
        cnt += n & 1
        n //= 2
    return cnt

N = int(input())
A = list(map(int, input().split()))
ans = 0
N2 = 1 << N
for s in range(N2//2):
    if popcount(s) != N//2:
        continue
    one = []
    zero = []
    for i in range(N):
        if (s >> i) & 1:
            one.append(i)
        else:
            zero.append(i)
    
    for tup in permutations(one):
        val = 0
        for i in range(N//2):
            val ^= A[tup[i]] + A[zero[i]]
        ans = max(ans, val)
print(ans)
0