結果

問題 No.698 ペアでチームを作ろう
ユーザー ronin_2020ronin_2020
提出日時 2021-11-20 16:17:49
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 506 ms / 1,000 ms
コード長 379 bytes
コンパイル時間 412 ms
コンパイル使用メモリ 10,720 KB
実行使用メモリ 8,720 KB
最終ジャッジ日時 2023-09-02 11:05:56
合計ジャッジ時間 6,049 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
7,924 KB
testcase_01 AC 15 ms
7,808 KB
testcase_02 AC 31 ms
7,916 KB
testcase_03 AC 15 ms
7,932 KB
testcase_04 AC 106 ms
8,256 KB
testcase_05 AC 482 ms
8,112 KB
testcase_06 AC 476 ms
8,076 KB
testcase_07 AC 505 ms
8,620 KB
testcase_08 AC 499 ms
8,720 KB
testcase_09 AC 506 ms
8,720 KB
testcase_10 AC 489 ms
8,552 KB
testcase_11 AC 501 ms
8,644 KB
testcase_12 AC 491 ms
8,688 KB
testcase_13 AC 500 ms
8,692 KB
testcase_14 AC 496 ms
8,644 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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


dp = [0] * (1 << N)

for S in range(1 << N):
    for u in range(N):
        if S & (1 << u):
            continue
        for v in range(u+1, N):
            if S & (1 << v):
                continue
            dp[S | (1 << u) | (1 << v)] = max(dp[S | (1 << u) | (1 << v)], dp[S] + (A[u] ^ A[v]))

# print(dp)
print(dp[-1])
0