結果
問題 | No.698 ペアでチームを作ろう |
ユーザー | lloyz |
提出日時 | 2022-10-12 00:05:38 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 103 ms / 1,000 ms |
コード長 | 564 bytes |
コンパイル時間 | 487 ms |
コンパイル使用メモリ | 87,100 KB |
実行使用メモリ | 77,360 KB |
最終ジャッジ日時 | 2023-09-08 01:38:06 |
合計ジャッジ時間 | 3,136 ms |
ジャッジサーバーID (参考情報) |
judge13 / judge15 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 70 ms
71,080 KB |
testcase_01 | AC | 69 ms
71,360 KB |
testcase_02 | AC | 90 ms
76,824 KB |
testcase_03 | AC | 70 ms
71,236 KB |
testcase_04 | AC | 95 ms
76,608 KB |
testcase_05 | AC | 96 ms
77,244 KB |
testcase_06 | AC | 100 ms
77,208 KB |
testcase_07 | AC | 103 ms
77,188 KB |
testcase_08 | AC | 102 ms
77,168 KB |
testcase_09 | AC | 102 ms
77,320 KB |
testcase_10 | AC | 102 ms
77,304 KB |
testcase_11 | AC | 101 ms
77,268 KB |
testcase_12 | AC | 102 ms
77,328 KB |
testcase_13 | AC | 102 ms
77,360 KB |
testcase_14 | AC | 102 ms
77,172 KB |
ソースコード
n = int(input()) A = list(map(int, input().split())) DP = [0 for _ in range(1 << n)] for bit in range(1, 1 << n): L = [] for i in range(n): if (bit >> i) & 1: L.append(i) if len(L) % 2 == 1: continue if len(L) == 2: i, j = L[0], L[1] DP[bit] = A[i] ^ A[j] else: for x in range(len(L)): for y in range(x + 1, len(L)): i, j = L[x], L[y] rbit = (1 << i) + (1 << j) DP[bit] = max(DP[bit], DP[bit - rbit] + (A[i] ^ A[j])) print(DP[-1])