結果

問題 No.699 ペアでチームを作ろう2
ユーザー mkawa2
提出日時 2020-01-26 09:43:48
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
AC  
実行時間 335 ms / 1,000 ms
コード長 650 bytes
コンパイル時間 482 ms
コンパイル使用メモリ 12,544 KB
実行使用メモリ 10,752 KB
最終ジャッジ日時 2024-09-14 10:52:09
合計ジャッジ時間 4,590 ms
ジャッジサーバーID
(参考情報)
judge1 / judge6
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 12
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys

sys.setrecursionlimit(10 ** 6)
def II(): return int(sys.stdin.readline())
def LI(): return list(map(int, sys.stdin.readline().split()))

def main():
    def dfs(xx=[]):
        if len(xx)==n//2:
            res=0
            for x in xx:
                res^=x
            return res
        i=used.index(False)
        used[i]=True
        res=0
        for j in range(i+1,n):
            if used[j]:continue
            used[j]=True
            ret=dfs(xx+[aa[i]+aa[j]])
            if ret>res:res=ret
            used[j]=False
        used[i]=False
        return res

    n=II()
    aa=LI()
    used=[False]*n
    print(dfs())

main()
0