結果

問題 No.698 ペアでチームを作ろう
ユーザー ikd
提出日時 2018-07-15 19:27:53
言語 Nim
(2.2.0)
結果
TLE  
実行時間 -
コード長 430 bytes
コンパイル時間 3,196 ms
コンパイル使用メモリ 67,044 KB
実行使用メモリ 13,756 KB
最終ジャッジ日時 2024-07-01 03:11:57
合計ジャッジ時間 6,164 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 2 TLE * 1 -- * 9
権限があれば一括ダウンロードができます

ソースコード

diff #

import strutils, sequtils

var
  n=stdin.readLine.parseInt
  a=stdin.readLine.split.map(parseInt)

proc f(bit: int): int=
  if bit==(1 shl n)-1:
    return 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)))
    return ret

echo f(0)
0