結果
問題 |
No.698 ペアでチームを作ろう
|
ユーザー |
![]() |
提出日時 | 2020-03-24 22:29:40 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
AC
|
実行時間 | 923 ms / 1,000 ms |
コード長 | 487 bytes |
コンパイル時間 | 287 ms |
コンパイル使用メモリ | 12,032 KB |
実行使用メモリ | 11,264 KB |
最終ジャッジ日時 | 2025-01-01 18:38:08 |
合計ジャッジ時間 | 9,890 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 12 |
ソースコード
import sys from itertools import combinations input = sys.stdin.readline N = int(input()) power = list(map(int, input().split())) dp = [0]*(1 << N) for bitset in range(1 << N): for (p1, power1), (p2, power2) in combinations(enumerate(power), r=2): if ((1 << p1) | (1 << p2)) & bitset: continue dp[bitset | (1 << p1) | (1 << p2)] = max( dp[bitset | (1 << p1) | (1 << p2)], dp[bitset] + (power1 ^ power2) ) print(dp[-1])