結果

問題 No.698 ペアでチームを作ろう
ユーザー ikd
提出日時 2018-07-15 19:19:57
言語 Nim
(2.2.8)
コンパイル:
nim --nimcache=~ --hints:off -o:a.out -d:release cpp _filename_
実行:
./a.out
結果
WA  
実行時間 -
コード長 464 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 3,494 ms
コンパイル使用メモリ 68,396 KB
実行使用メモリ 16,512 KB
最終ジャッジ日時 2026-03-21 20:15:23
合計ジャッジ時間 23,604 ms
ジャッジサーバーID
(参考情報)
judge3_1 / judge1_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample WA * 3
other WA * 2 TLE * 10
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

import strutils, sequtils

var
  n=stdin.readLine.parseInt
  a=stdin.readLine.split.map(parseInt)
  memo=newSeq[int](1 shl n)

proc f(bit: int): int=
  if bit==(1 shl n)-1:
    memo[bit]=0
  else:
    var ret=0
    for i in 0..<n:
      if (bit and (1 shl i))>0:
        continue
      for j in 0..<i:
        if (bit and (1 shl j))>0:        
          continue
        ret=max(ret, (a[i] xor a[j])+f(bit xor (1 shl i) xor (1 shl j)))
    memo[bit]=ret

echo f(0)
0