結果

問題 No.698 ペアでチームを作ろう
ユーザー SI1000-githubSI1000-github
提出日時 2022-10-25 12:13:05
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 123 ms / 1,000 ms
コード長 799 bytes
コンパイル時間 280 ms
コンパイル使用メモリ 86,904 KB
実行使用メモリ 77,548 KB
最終ジャッジ日時 2023-09-16 11:09:54
合計ジャッジ時間 2,825 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 72 ms
71,080 KB
testcase_01 AC 71 ms
71,056 KB
testcase_02 AC 90 ms
76,424 KB
testcase_03 AC 70 ms
71,252 KB
testcase_04 AC 92 ms
76,516 KB
testcase_05 AC 114 ms
77,032 KB
testcase_06 AC 120 ms
77,300 KB
testcase_07 AC 121 ms
77,548 KB
testcase_08 AC 121 ms
76,992 KB
testcase_09 AC 120 ms
77,432 KB
testcase_10 AC 120 ms
77,012 KB
testcase_11 AC 123 ms
77,244 KB
testcase_12 AC 121 ms
77,084 KB
testcase_13 AC 121 ms
76,964 KB
testcase_14 AC 121 ms
77,004 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#!/usr/bin/python
# -*- coding: utf-8 -*-

# import
from sys import stdin, setrecursionlimit
setrecursionlimit(10**8)

def int_map():
    return map(int,input().split())

def int_list():
    return list(map(int,input().split()))

def int_mtx(N):
    x = [list(map(int, stdin.readline().split())) for _ in range(N)]
    return x

def str_mtx(N):
    x = [list(stdin.readline()[:-1]) for _ in range(N)]
    return x

def print_space(l):
    return print(" ".join([str(x) for x in l]))



"""    main code    """

N = int(input())
A = int_list()

dp = [0 for _ in range(2**N)]

for s in range(2**N):
    for u in range(N):
        for v in range(u+1,N):
            if s >> u & 1 == 0 and s >> v & 1 == 0:
                dp[s+2**u+2**v] = max(dp[s+2**u+2**v], dp[s] + (A[u]^A[v]))

print(dp[2**N-1])
0