結果

問題 No.698 ペアでチームを作ろう
ユーザー uindouuindou
提出日時 2019-09-30 00:36:23
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 720 ms / 1,000 ms
コード長 359 bytes
コンパイル時間 238 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 11,520 KB
最終ジャッジ日時 2024-04-14 07:34:16
合計ジャッジ時間 8,726 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 31 ms
10,624 KB
testcase_01 AC 30 ms
10,880 KB
testcase_02 AC 52 ms
10,624 KB
testcase_03 AC 30 ms
10,752 KB
testcase_04 AC 156 ms
10,880 KB
testcase_05 AC 713 ms
10,752 KB
testcase_06 AC 676 ms
10,880 KB
testcase_07 AC 718 ms
11,264 KB
testcase_08 AC 713 ms
11,392 KB
testcase_09 AC 720 ms
11,392 KB
testcase_10 AC 716 ms
11,520 KB
testcase_11 AC 717 ms
11,392 KB
testcase_12 AC 715 ms
11,392 KB
testcase_13 AC 712 ms
11,392 KB
testcase_14 AC 717 ms
11,264 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N = int(input())
A = [int(i) for i in input().split()]
DP = [0]*(1<<N)

def chmax(DP,i,j,k):
    DP[i+j] = DP[i]+k if DP[i+j]<DP[i]+k else DP[i+j]
    return;

N_bit = 1<<N
for i in range(N_bit):
    for a in range(N):
        for b in range(a+1,N):
            if((i & 1<<a | i & 1<<b) == 0):
                chmax(DP,i,(1<<a)+(1<<b),A[a]^A[b])
print(DP[-1])
0