結果

問題 No.698 ペアでチームを作ろう
ユーザー Nikkuniku029Nikkuniku029
提出日時 2021-08-29 10:12:12
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 270 ms / 1,000 ms
コード長 519 bytes
コンパイル時間 245 ms
コンパイル使用メモリ 12,544 KB
実行使用メモリ 11,264 KB
最終ジャッジ日時 2024-05-01 21:17:22
合計ジャッジ時間 3,612 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 33 ms
10,752 KB
testcase_01 AC 30 ms
10,752 KB
testcase_02 AC 38 ms
10,752 KB
testcase_03 AC 30 ms
10,752 KB
testcase_04 AC 75 ms
10,880 KB
testcase_05 AC 241 ms
10,880 KB
testcase_06 AC 244 ms
10,880 KB
testcase_07 AC 261 ms
11,136 KB
testcase_08 AC 260 ms
11,008 KB
testcase_09 AC 262 ms
11,008 KB
testcase_10 AC 261 ms
11,136 KB
testcase_11 AC 270 ms
11,008 KB
testcase_12 AC 260 ms
11,264 KB
testcase_13 AC 254 ms
11,136 KB
testcase_14 AC 259 ms
11,136 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n = int(input())
A = list(map(int, input().split()))

dp = [0]*(1 << n)
for s in range(1 << n):
    tmp = 0
    for c in range(n):
        if (s >> c) & 1:
            tmp += 1
    if tmp % 2 == 1:
        continue

    for a in range(n):
        if s & (1 << a) == 0:
            for b in range(a+1, n):
                if s & (1 << b) == 0:
                    if dp[s | ((1 << a) | (1 << b))] < dp[s]+ (A[a] ^ A[b]):
                        dp[s | ((1 << a) | (1 << b))] = dp[s]+(A[a] ^ A[b])

print(dp[(1 << n)-1])
0