結果

問題 No.699 ペアでチームを作ろう2
ユーザー neko_the_shadowneko_the_shadow
提出日時 2019-03-15 18:40:22
言語 Ruby
(3.3.0)
結果
TLE  
実行時間 -
コード長 390 bytes
コンパイル時間 60 ms
コンパイル使用メモリ 11,460 KB
実行使用メモリ 22,368 KB
最終ジャッジ日時 2023-09-14 12:38:05
合計ジャッジ時間 4,311 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 83 ms
22,368 KB
testcase_01 AC 83 ms
15,128 KB
testcase_02 TLE -
testcase_03 AC 84 ms
15,144 KB
testcase_04 TLE -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

n = gets.to_i
a = gets.split.map(&:to_i)

stack = [[[], 0]]
ans = 0
until stack.empty?
  e, bit = stack.pop
  if e.size == n / 2
    ans = [ans, e.reduce{|x, y| x ^ y}].max
  else 
    (0...n).each do |x|
      ((x + 1)...n).each do |y|
        stack << [[*e, a[x] + a[y]], (bit | (1 << x) | (1 << y))] if (bit & (1 << x)) == 0 && (bit & (1 << y)) == 0
      end
    end
  end
end

puts ans
0