結果

問題 No.699 ペアでチームを作ろう2
ユーザー mkawa2
提出日時 2020-01-26 09:43:48
言語 Python3
(3.14.3 + numpy 2.4.4 + scipy 1.17.1)
コンパイル:
python3 -mpy_compile _filename_
実行:
python3 _filename_
結果
AC  
実行時間 309 ms / 1,000 ms
コード長 650 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 347 ms
コンパイル使用メモリ 20,956 KB
実行使用メモリ 15,356 KB
最終ジャッジ日時 2026-04-04 12:11:12
合計ジャッジ時間 4,601 ms
ジャッジサーバーID
(参考情報)
judge5_1 / judge1_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 12
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

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