結果

問題 No.698 ペアでチームを作ろう
ユーザー irumo8202irumo8202
提出日時 2022-01-28 11:50:28
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 128 ms / 1,000 ms
コード長 441 bytes
コンパイル時間 533 ms
コンパイル使用メモリ 86,840 KB
実行使用メモリ 77,144 KB
最終ジャッジ日時 2023-08-27 22:57:32
合計ジャッジ時間 3,238 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 72 ms
71,004 KB
testcase_01 AC 70 ms
71,372 KB
testcase_02 AC 84 ms
76,320 KB
testcase_03 AC 71 ms
71,284 KB
testcase_04 AC 88 ms
77,144 KB
testcase_05 AC 127 ms
76,856 KB
testcase_06 AC 126 ms
76,848 KB
testcase_07 AC 127 ms
76,904 KB
testcase_08 AC 126 ms
76,924 KB
testcase_09 AC 126 ms
76,848 KB
testcase_10 AC 126 ms
76,952 KB
testcase_11 AC 128 ms
76,904 KB
testcase_12 AC 128 ms
76,640 KB
testcase_13 AC 127 ms
76,948 KB
testcase_14 AC 126 ms
76,840 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N = int(input())
A = list(map(int, input().split()))


def dfs(tot, used):
    if used == (1 << N) - 1:
        return tot

    res = 0
    for i in range(N):
        if used >> i & 1:
            continue
        for j in range(i + 1, N):
            if used >> j & 1:
                continue
            tmp = dfs(tot + (A[i] ^ A[j]), used | 1 << i | 1 << j)
            res = max(res, tmp)
        break
    return res


print(dfs(0, 0))
0