結果
| 問題 | No.698 ペアでチームを作ろう |
| ユーザー |
みあえ
|
| 提出日時 | 2024-04-01 01:01:01 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 146 ms / 1,000 ms |
| コード長 | 553 bytes |
| コンパイル時間 | 196 ms |
| コンパイル使用メモリ | 81,884 KB |
| 実行使用メモリ | 76,528 KB |
| 最終ジャッジ日時 | 2024-09-30 21:33:06 |
| 合計ジャッジ時間 | 2,710 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 12 |
ソースコード
from itertools import combinations
def solve(N, A):
dp = [-float("inf")] * (1 << N)
dp[0] = 0
for V in range(1 << N):
for i, j in combinations(range(N), 2):
ai = A[i]
aj = A[j]
if not ((V >> i) & 1) and not ((V >> j) & 1):
VV = V | (1 << i) | (1 << j)
dp[VV] = max(dp[VV], dp[V] + (ai ^ aj))
return dp[-1]
def main():
N = int(input())
A = list(map(int, input().split()))
ans = solve(N, A)
print(ans)
if __name__ == "__main__":
main()
みあえ