結果

問題 No.699 ペアでチームを作ろう2
ユーザー GrayCoderGrayCoder
提出日時 2019-08-12 21:51:53
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 547 ms / 1,000 ms
コード長 709 bytes
コンパイル時間 155 ms
コンパイル使用メモリ 11,996 KB
実行使用メモリ 15,340 KB
最終ジャッジ日時 2023-10-17 14:39:59
合計ジャッジ時間 6,625 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 69 ms
9,960 KB
testcase_01 AC 65 ms
9,960 KB
testcase_02 AC 62 ms
9,976 KB
testcase_03 AC 62 ms
9,960 KB
testcase_04 AC 97 ms
10,360 KB
testcase_05 AC 480 ms
11,116 KB
testcase_06 AC 477 ms
11,116 KB
testcase_07 AC 519 ms
15,340 KB
testcase_08 AC 512 ms
15,340 KB
testcase_09 AC 547 ms
15,340 KB
testcase_10 AC 542 ms
15,340 KB
testcase_11 AC 429 ms
15,340 KB
testcase_12 AC 268 ms
15,340 KB
testcase_13 AC 267 ms
15,340 KB
testcase_14 AC 274 ms
15,340 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import operator
from functools import reduce
from itertools import compress
from sys import stdin

def pair(a):
    ret = []
    p = [0] * (len(a) // 2)
    def func(a, i):
        n = len(a)
        if n == 2:
            p[i] = a[0] + a[1]
            ret.append(reduce(operator.xor, p))
            return

        msk = [1] * n
        msk[0] = 0
        for j in range(1, n):
            msk[j] = 0
            x = list(compress(a, msk))
            p[i] = a[0] + a[j]
            func(x, i + 1)
            msk[j] = 1
    func(a, 0)
    return ret

def main():
    N = int(input())
    A = tuple(map(int, input().split()))

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

input = lambda: stdin.readline()
main()
0