結果

問題 No.699 ペアでチームを作ろう2
ユーザー rlangevinrlangevin
提出日時 2023-02-03 00:01:50
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 985 ms / 1,000 ms
コード長 568 bytes
コンパイル時間 529 ms
コンパイル使用メモリ 86,976 KB
実行使用メモリ 77,448 KB
最終ジャッジ日時 2023-09-15 04:43:32
合計ジャッジ時間 11,461 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 74 ms
71,624 KB
testcase_01 AC 74 ms
71,212 KB
testcase_02 AC 87 ms
76,580 KB
testcase_03 AC 72 ms
71,500 KB
testcase_04 AC 126 ms
77,344 KB
testcase_05 AC 970 ms
77,404 KB
testcase_06 AC 971 ms
77,040 KB
testcase_07 AC 968 ms
77,300 KB
testcase_08 AC 972 ms
76,984 KB
testcase_09 AC 985 ms
77,288 KB
testcase_10 AC 970 ms
77,444 KB
testcase_11 AC 973 ms
77,292 KB
testcase_12 AC 972 ms
77,412 KB
testcase_13 AC 971 ms
77,280 KB
testcase_14 AC 971 ms
77,448 KB
権限があれば一括ダウンロードができます

ソースコード

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