結果

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

テストケース

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

ソースコード

diff #

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

dp = Array.new(2 ** n, 0)
dp.size.times do |bit|
  (0...n).each do |x|
    ((x + 1)...n).each do |y|
      next unless (bit & (1 << x)) == 0 && (bit & (1 << y)) == 0
      nxt = bit | (1 << x) | (1 << y)
      dp[nxt] = [dp[nxt], dp[bit] ^ (a[x] + a[y])].max
    end
  end
end

p dp.last
0