結果

問題 No.698 ペアでチームを作ろう
ユーザー むらため
提出日時 2019-01-26 16:09:22
言語 Nim
(2.2.8)
コンパイル:
nim --nimcache=~ --hints:off -o:a.out -d:release cpp _filename_
実行:
./a.out
結果
AC  
実行時間 546 ms / 1,000 ms
コード長 860 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 2,320 ms
コンパイル使用メモリ 69,840 KB
実行使用メモリ 7,716 KB
最終ジャッジ日時 2026-03-22 10:10:43
合計ジャッジ時間 6,980 ms
ジャッジサーバーID
(参考情報)
judge3_1 / judge1_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 12
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

import sequtils,algorithm
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

# 14C2 * 12C2 * 10C2 * 8C2 * 6C2 * 4C2 * 2C2
# 高々:1*6*15*28*45*66*91 なので全て列挙
# proc test() =
#   var A = toSeq(1..6)
#   while true:
#     echo A
#     # A.reverse(A.len div 2, A.len - 1)
#     if not A.nextPermutation(): return
# test()
let n = scan()
let A = newSeqWith(n,scan())
proc solve(A:seq[int]) : int =
  var A = A.sorted(cmp)
  while true:
    var s = 0
    for i in 0..<n div 2:
      s += A[i] xor A[i + n div 2]
    result .max= s
    A.reverse(n div 2,A.len-1)
    if not A.nextPermutation() : return
echo solve(A)
0