結果

問題 No.698 ペアでチームを作ろう
ユーザー ikdikd
提出日時 2018-07-15 19:19:57
言語 Nim
(2.0.0)
結果
WA  
実行時間 -
コード長 464 bytes
コンパイル時間 4,735 ms
コンパイル使用メモリ 68,324 KB
実行使用メモリ 10,576 KB
最終ジャッジ日時 2023-09-13 18:32:53
合計ジャッジ時間 6,531 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 TLE -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

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