結果

問題 No.698 ペアでチームを作ろう
ユーザー rlangevinrlangevin
提出日時 2023-01-31 00:18:18
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 112 ms / 1,000 ms
コード長 413 bytes
コンパイル時間 325 ms
コンパイル使用メモリ 87,088 KB
実行使用メモリ 77,132 KB
最終ジャッジ日時 2023-09-12 20:22:40
合計ジャッジ時間 2,973 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 76 ms
71,208 KB
testcase_01 AC 76 ms
71,380 KB
testcase_02 AC 101 ms
76,300 KB
testcase_03 AC 77 ms
71,444 KB
testcase_04 AC 95 ms
76,376 KB
testcase_05 AC 111 ms
76,832 KB
testcase_06 AC 110 ms
76,892 KB
testcase_07 AC 109 ms
76,896 KB
testcase_08 AC 111 ms
76,872 KB
testcase_09 AC 111 ms
76,924 KB
testcase_10 AC 111 ms
76,952 KB
testcase_11 AC 112 ms
77,020 KB
testcase_12 AC 111 ms
76,868 KB
testcase_13 AC 112 ms
77,132 KB
testcase_14 AC 112 ms
76,644 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N = int(input())
A = list(map(int, input().split()))
N2 = 1 << N
inf = 10 ** 18
dp = [-inf] * N2
dp[0] = 0
for s in range(N2):
    for a in range(N):
        for b in range(a + 1, N):
            if (s >> a) & 1:
                continue
            if (s >> b) & 1:
                continue
            ns = s | (1 << a) | (1 << b)
            dp[ns] = max(dp[ns], dp[s] + (A[a] ^ A[b]))
print(dp[-1])           
0