結果

問題 No.698 ペアでチームを作ろう
ユーザー 👑 rin204rin204
提出日時 2022-03-23 16:03:17
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 99 ms / 1,000 ms
コード長 474 bytes
コンパイル時間 123 ms
コンパイル使用メモリ 82,428 KB
実行使用メモリ 76,160 KB
最終ジャッジ日時 2024-04-20 00:03:28
合計ジャッジ時間 1,992 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 32 ms
52,480 KB
testcase_01 AC 33 ms
51,840 KB
testcase_02 AC 52 ms
64,896 KB
testcase_03 AC 35 ms
52,096 KB
testcase_04 AC 53 ms
75,888 KB
testcase_05 AC 86 ms
75,648 KB
testcase_06 AC 90 ms
76,084 KB
testcase_07 AC 93 ms
75,756 KB
testcase_08 AC 98 ms
75,648 KB
testcase_09 AC 94 ms
75,648 KB
testcase_10 AC 99 ms
75,904 KB
testcase_11 AC 92 ms
75,520 KB
testcase_12 AC 92 ms
76,160 KB
testcase_13 AC 93 ms
75,904 KB
testcase_14 AC 94 ms
75,788 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n = int(input())
A = list(map(int, input().split()))
used = [False] * n

def dfs(i, x):
    if 2 * i == n:
        return x
    
    for j in range(n):
        if not used[j]:
            used[j] = True
            a = A[j]
            break
    ret = 0
    for k in range(j + 1, n):
        if not used[k]:
            used[k] = True
            ret = max(ret, dfs(i + 1, x + (a ^ A[k])))
            used[k] = False
    used[j] = False
    return ret
    
print(dfs(0, 0))
0