結果

問題 No.698 ペアでチームを作ろう
ユーザー shinichishinichi
提出日時 2021-08-22 17:31:12
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 89 ms / 1,000 ms
コード長 408 bytes
コンパイル時間 164 ms
コンパイル使用メモリ 82,432 KB
実行使用メモリ 76,544 KB
最終ジャッジ日時 2024-04-24 07:37:47
合計ジャッジ時間 2,078 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 41 ms
52,096 KB
testcase_01 AC 41 ms
52,224 KB
testcase_02 AC 64 ms
64,384 KB
testcase_03 AC 40 ms
51,840 KB
testcase_04 AC 66 ms
67,840 KB
testcase_05 AC 78 ms
76,288 KB
testcase_06 AC 80 ms
76,288 KB
testcase_07 AC 82 ms
76,416 KB
testcase_08 AC 86 ms
76,288 KB
testcase_09 AC 88 ms
76,544 KB
testcase_10 AC 86 ms
76,160 KB
testcase_11 AC 87 ms
76,288 KB
testcase_12 AC 89 ms
76,160 KB
testcase_13 AC 82 ms
76,416 KB
testcase_14 AC 84 ms
76,288 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from itertools import combinations
N = int(input())
A = list(map(int, input().split()))

dp = [0] * (2**N)
for bit in range(2**N):
    rest = []
    for i in range(N):
        if (bit >> i) & 1:
            continue
        rest.append(i)
    if len(rest) % 2:
        continue

    for i, j in combinations(rest, 2):
        dp[bit|1<<i|1<<j] = max(dp[bit|1<<i|1<<j], dp[bit]+(A[i]^A[j]))

print(dp[2**N-1])
0