結果
問題 |
No.698 ペアでチームを作ろう
|
ユーザー |
![]() |
提出日時 | 2023-01-31 00:18:18 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 78 ms / 1,000 ms |
コード長 | 413 bytes |
コンパイル時間 | 180 ms |
コンパイル使用メモリ | 82,424 KB |
実行使用メモリ | 76,128 KB |
最終ジャッジ日時 | 2024-06-30 07:59:48 |
合計ジャッジ時間 | 1,843 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 12 |
ソースコード
N = int(input()) A = list(map(int, input().split())) N2 = 1 << N inf = 10 ** 18 dp = [-inf] * N2 dp[0] = 0 for s in range(N2): for a in range(N): for b in range(a + 1, N): if (s >> a) & 1: continue if (s >> b) & 1: continue ns = s | (1 << a) | (1 << b) dp[ns] = max(dp[ns], dp[s] + (A[a] ^ A[b])) print(dp[-1])