結果

問題 No.698 ペアでチームを作ろう
ユーザー 👑 H20H20
提出日時 2021-05-27 10:31:39
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 99 ms / 1,000 ms
コード長 498 bytes
コンパイル時間 307 ms
コンパイル使用メモリ 82,176 KB
実行使用メモリ 76,032 KB
最終ジャッジ日時 2024-04-23 23:49:18
合計ジャッジ時間 2,214 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 41 ms
51,712 KB
testcase_01 AC 42 ms
51,712 KB
testcase_02 AC 62 ms
64,768 KB
testcase_03 AC 41 ms
51,456 KB
testcase_04 AC 67 ms
70,016 KB
testcase_05 AC 93 ms
75,904 KB
testcase_06 AC 97 ms
75,776 KB
testcase_07 AC 97 ms
75,264 KB
testcase_08 AC 96 ms
75,520 KB
testcase_09 AC 96 ms
75,776 KB
testcase_10 AC 94 ms
75,648 KB
testcase_11 AC 96 ms
75,776 KB
testcase_12 AC 99 ms
75,392 KB
testcase_13 AC 95 ms
76,032 KB
testcase_14 AC 96 ms
75,520 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def main():
    N = int(input())
    A = list(map(int,input().split()))
    dp = [0]*(1<<N)
    for s in range(0, 1<<N):#集合を添字の小さい順に試す
        for i in range(N):#全ての要素のペアを考える
            for j in range(i+1,N):
                if ((s>>i)&1)==0 and ((s>>j)&1)==0:#i in not s and j in not s
                    if dp[s+(1<<i)+(1<<j)]<dp[s]+(A[i]^A[j]):
                        dp[s+(1<<i)+(1<<j)]=dp[s]+(A[i]^A[j])
    return dp[-1]
print(main())    
0