結果

問題 No.698 ペアでチームを作ろう
ユーザー wgrapewgrape
提出日時 2023-12-12 09:49:10
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 87 ms / 1,000 ms
コード長 584 bytes
コンパイル時間 837 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 75,788 KB
最終ジャッジ日時 2023-12-12 09:49:13
合計ジャッジ時間 2,312 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 34 ms
53,460 KB
testcase_01 AC 34 ms
53,460 KB
testcase_02 AC 52 ms
66,372 KB
testcase_03 AC 34 ms
53,460 KB
testcase_04 AC 63 ms
72,608 KB
testcase_05 AC 87 ms
75,680 KB
testcase_06 AC 75 ms
75,684 KB
testcase_07 AC 76 ms
75,684 KB
testcase_08 AC 74 ms
75,788 KB
testcase_09 AC 73 ms
75,668 KB
testcase_10 AC 72 ms
75,656 KB
testcase_11 AC 75 ms
75,684 KB
testcase_12 AC 72 ms
75,660 KB
testcase_13 AC 66 ms
75,640 KB
testcase_14 AC 81 ms
75,684 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

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

def popcnt(x):
    res = 0
    while x:
        res += (x & 1)
        x >>= 1
    return res
    
for status in range(1 << N):
    if popcnt(status) & 1:
        continue
    for i in range(N):
        if (status >> i) & 1:
            continue
        for j in range(i + 1, N):
            if (status >> j) & 1:
                continue
            next_status = status | (1 << i) | (1 << j)
            dp[next_status] = max(dp[next_status], dp[status] + (A[i] ^ A[j]))
            
print(dp[-1])

    
    
0