結果

問題 No.698 ペアでチームを作ろう
ユーザー convexineqconvexineq
提出日時 2021-03-30 03:35:13
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 113 ms / 1,000 ms
コード長 392 bytes
コンパイル時間 1,422 ms
コンパイル使用メモリ 87,072 KB
実行使用メモリ 77,892 KB
最終ジャッジ日時 2023-08-20 00:59:48
合計ジャッジ時間 3,750 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 92 ms
71,384 KB
testcase_01 AC 92 ms
71,256 KB
testcase_02 AC 92 ms
71,660 KB
testcase_03 AC 92 ms
71,496 KB
testcase_04 AC 98 ms
77,212 KB
testcase_05 AC 107 ms
77,272 KB
testcase_06 AC 108 ms
77,620 KB
testcase_07 AC 111 ms
77,724 KB
testcase_08 AC 109 ms
77,760 KB
testcase_09 AC 109 ms
77,620 KB
testcase_10 AC 108 ms
77,892 KB
testcase_11 AC 113 ms
77,860 KB
testcase_12 AC 109 ms
77,452 KB
testcase_13 AC 108 ms
77,688 KB
testcase_14 AC 107 ms
77,688 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import defaultdict
n = int(input())
*a, = map(int,input().split())
d = {2**n-1:0}
for _ in range(n//2):
    nd = defaultdict(int)
    for k,v in d.items():
        idx = (k&-k).bit_length() - 1
        k &= k-1
        for i in range(idx+1,n):
            if k>>i&1:
                nk = k^(1<<i)
                nd[nk] = max(nd[nk], v + (a[idx]^a[i]))
    d = nd
print(d[0])
0