結果

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

ソースコード

diff #

from operator import xor
from collections import deque
from functools import reduce
from sys import stdin

def pair(lst):
    def func(a, b):
        n = len(a)
        if n == 2:
            ret.append(reduce(xor, b + [a[0] + a[1]]))
            return
        a0 = a.popleft()
        for _ in [0] * (n - 1):
            ai = a.popleft()
            arg2 = b + [a0 + ai]
            func(a.copy(), arg2)
            a.append(ai)
    lst = deque(lst)
    ret = []
    func(lst, [])
    return ret

def main():
    input = lambda: stdin.readline()
    N = int(input())
    A = list(map(int, input().split()))

    ans = max(pair(A))
    print(ans)

main()
0