結果
| 問題 | No.698 ペアでチームを作ろう |
| ユーザー |
|
| 提出日時 | 2024-10-13 12:48:48 |
| 言語 | PyPy3 (7.3.17) |
| 結果 |
AC
|
| 実行時間 | 249 ms / 1,000 ms |
| コード長 | 477 bytes |
| 記録 | |
| コンパイル時間 | 266 ms |
| コンパイル使用メモリ | 85,504 KB |
| 実行使用メモリ | 83,072 KB |
| 最終ジャッジ日時 | 2026-04-30 22:48:25 |
| 合計ジャッジ時間 | 4,490 ms |
|
ジャッジサーバーID (参考情報) |
judge3_0 / judge2_1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 12 |
ソースコード
from itertools import combinations
N = int(input())
A = list(map(int,input().split()))
dp = {}
for z in combinations(range(N),2):
dp[z] = A[z[0]]^A[z[1]]
for n in range(4,N+1,2):
for z in combinations(range(N),n):
dp[z] = 0
for y in combinations(z,2):
z1 = list(z)
z1.remove(y[0])
z1.remove(y[1])
z1 = tuple(z1)
dp[z] = max(dp[z],dp[z1]+(A[y[0]]^A[y[1]]))
ans = tuple(range(N))
print(dp[ans])