結果
| 問題 | No.698 ペアでチームを作ろう |
| ユーザー |
|
| 提出日時 | 2019-01-24 04:04:04 |
| 言語 | Nim (2.2.0) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 793 bytes |
| 記録 | |
| コンパイル時間 | 2,331 ms |
| コンパイル使用メモリ | 61,296 KB |
| 実行使用メモリ | 13,752 KB |
| 最終ジャッジ日時 | 2024-07-01 10:40:55 |
| 合計ジャッジ時間 | 4,792 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 2 TLE * 1 -- * 9 |
ソースコード
import sequtils
template `max=`*(x,y) = x = max(x,y)
template `min=`*(x,y) = x = min(x,y)
proc getchar_unlocked():char {. importc:"getchar_unlocked",header: "<stdio.h>" .}
proc scan(): int =
while true:
let k = getchar_unlocked()
if k < '0': break
result = 10 * result + k.ord - '0'.ord
let n = scan()
let A = newSeqWith(n,scan())
if n == 2 :
echo A[0] xor A[1]
quit 0
# 14C2 * 12C2 * 10C2 * 8C2 * 6C2 * 4C2 * 2C2
# 高々:1*6*15*28*45*66*91 なので全て列挙
var dp: array[1677_7217,int]
proc solve(s:int):int =
if dp[s] > 0 : return dp[s]
for a in 0..<n:
if ((1 shl a) and s) > 0 : continue
for b in (a+1)..<n:
if ((1 shl b) and s) > 0 : continue
result .max= solve(s or (1 shl a) or (1 shl b)) + (A[a] xor A[b])
dp[s] = result
echo solve(0)