結果

問題 No.698 ペアでチームを作ろう
ユーザー H20
提出日時 2021-05-27 10:31:39
言語 PyPy3
(7.3.17)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
AC  
実行時間 52 ms / 1,000 ms
コード長 498 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 1,758 ms
コンパイル使用メモリ 85,084 KB
実行使用メモリ 80,712 KB
最終ジャッジ日時 2026-05-06 08:19:26
合計ジャッジ時間 3,352 ms
ジャッジサーバーID
(参考情報)
judge3_0 / judge1_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 12
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

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