結果

問題 No.699 ペアでチームを作ろう2
ユーザー convexineqconvexineq
提出日時 2021-03-30 03:43:07
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 189 ms / 1,000 ms
コード長 288 bytes
コンパイル時間 886 ms
コンパイル使用メモリ 86,424 KB
実行使用メモリ 78,940 KB
最終ジャッジ日時 2023-08-20 01:08:06
合計ジャッジ時間 4,356 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 73 ms
71,152 KB
testcase_01 AC 72 ms
70,964 KB
testcase_02 AC 86 ms
76,300 KB
testcase_03 AC 73 ms
71,312 KB
testcase_04 AC 118 ms
77,492 KB
testcase_05 AC 179 ms
78,192 KB
testcase_06 AC 178 ms
77,712 KB
testcase_07 AC 178 ms
78,940 KB
testcase_08 AC 178 ms
77,812 KB
testcase_09 AC 189 ms
78,888 KB
testcase_10 AC 182 ms
78,340 KB
testcase_11 AC 181 ms
78,256 KB
testcase_12 AC 179 ms
77,724 KB
testcase_13 AC 181 ms
77,348 KB
testcase_14 AC 181 ms
77,772 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n = int(input())
*a, = map(int,input().split())

def dfs(k,v):
    if k==0:
        return v
    c = 0
    idx = (k&-k).bit_length() - 1
    k ^= 1<<idx
    for i in range(idx+1,n):
        if k>>i&1:
            c = max(c,dfs(k^(1<<i),v^(a[idx]+a[i])))
    return c

print(dfs(2**n-1,0))
0