結果

問題 No.698 ペアでチームを作ろう
ユーザー ryomacryomac
提出日時 2024-01-11 22:47:26
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 101 ms / 1,000 ms
コード長 397 bytes
コンパイル時間 2,562 ms
コンパイル使用メモリ 81,444 KB
実行使用メモリ 76,084 KB
最終ジャッジ日時 2024-01-11 22:47:36
合計ジャッジ時間 9,875 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 35 ms
53,460 KB
testcase_01 AC 36 ms
53,460 KB
testcase_02 AC 54 ms
66,260 KB
testcase_03 AC 34 ms
53,460 KB
testcase_04 AC 54 ms
68,316 KB
testcase_05 AC 76 ms
73,232 KB
testcase_06 AC 90 ms
75,572 KB
testcase_07 AC 89 ms
75,564 KB
testcase_08 AC 97 ms
76,084 KB
testcase_09 AC 91 ms
75,564 KB
testcase_10 AC 101 ms
75,564 KB
testcase_11 AC 96 ms
76,084 KB
testcase_12 AC 89 ms
75,564 KB
testcase_13 AC 89 ms
75,564 KB
testcase_14 AC 90 ms
75,564 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

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