結果

問題 No.698 ペアでチームを作ろう
ユーザー H3PO4H3PO4
提出日時 2022-10-05 13:39:48
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 122 ms / 1,000 ms
コード長 447 bytes
コンパイル時間 586 ms
コンパイル使用メモリ 87,228 KB
実行使用メモリ 77,728 KB
最終ジャッジ日時 2023-08-30 05:07:05
合計ジャッジ時間 3,405 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 72 ms
71,324 KB
testcase_01 AC 73 ms
71,300 KB
testcase_02 AC 120 ms
76,948 KB
testcase_03 AC 72 ms
71,104 KB
testcase_04 AC 108 ms
77,400 KB
testcase_05 AC 114 ms
77,584 KB
testcase_06 AC 119 ms
77,588 KB
testcase_07 AC 117 ms
77,556 KB
testcase_08 AC 117 ms
77,652 KB
testcase_09 AC 112 ms
77,624 KB
testcase_10 AC 112 ms
77,648 KB
testcase_11 AC 115 ms
77,728 KB
testcase_12 AC 122 ms
77,616 KB
testcase_13 AC 116 ms
77,312 KB
testcase_14 AC 116 ms
77,660 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N = int(input())
A = tuple(map(int, input().split()))

bit_count = lambda b: bin(b).count("1")

dp = [0] * (1 << N)
for b in range(1 << N):
    if bit_count(b) % 2:
        continue
    for i in range(N):
        if (b >> i) & 1:
            continue
        for j in range(i + 1, N):
            if (b >> j) & 1:
                continue
            c = b | (1 << i) | (1 << j)
            dp[c] = max(dp[c], dp[b] + (A[i] ^ A[j]))
print(dp[-1])
0