結果

問題 No.698 ペアでチームを作ろう
ユーザー brthyyjpbrthyyjp
提出日時 2021-02-10 20:56:01
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 113 ms / 1,000 ms
コード長 443 bytes
コンパイル時間 305 ms
コンパイル使用メモリ 87,068 KB
実行使用メモリ 77,388 KB
最終ジャッジ日時 2023-09-22 16:49:32
合計ジャッジ時間 2,716 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 73 ms
71,128 KB
testcase_01 AC 72 ms
71,256 KB
testcase_02 AC 96 ms
76,452 KB
testcase_03 AC 72 ms
71,428 KB
testcase_04 AC 97 ms
76,412 KB
testcase_05 AC 101 ms
76,720 KB
testcase_06 AC 106 ms
77,028 KB
testcase_07 AC 103 ms
76,392 KB
testcase_08 AC 103 ms
76,228 KB
testcase_09 AC 110 ms
77,388 KB
testcase_10 AC 107 ms
76,796 KB
testcase_11 AC 113 ms
77,016 KB
testcase_12 AC 113 ms
77,140 KB
testcase_13 AC 108 ms
76,816 KB
testcase_14 AC 113 ms
77,064 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

dp = [0]*(1<<n)
for s in range(1<<n):
    p = 0
    for i in range(n):
        if (s>>i)&1:
            p += 1
    if p%2 != 0:
        continue
    for i in range(n-1):
        if (s>>i)&1:
            continue
        for j in range(i+1, n):
            if (s>>j)&1:
                continue
            dp[s|1<<i|1<<j] = max(dp[s|1<<i|1<<j], dp[s]+(A[i]^A[j]))
#print(dp)
print(dp[-1])
0