結果

問題 No.698 ペアでチームを作ろう
ユーザー cympfhcympfh
提出日時 2018-06-13 15:28:39
言語 Ruby
(3.3.0)
結果
AC  
実行時間 329 ms / 1,000 ms
コード長 292 bytes
コンパイル時間 335 ms
コンパイル使用メモリ 11,264 KB
実行使用メモリ 15,416 KB
最終ジャッジ日時 2023-09-13 03:53:17
合計ジャッジ時間 5,188 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 81 ms
15,100 KB
testcase_01 AC 81 ms
15,172 KB
testcase_02 AC 85 ms
15,244 KB
testcase_03 AC 80 ms
15,344 KB
testcase_04 AC 101 ms
15,408 KB
testcase_05 AC 325 ms
15,416 KB
testcase_06 AC 328 ms
15,296 KB
testcase_07 AC 326 ms
15,240 KB
testcase_08 AC 327 ms
15,396 KB
testcase_09 AC 325 ms
15,256 KB
testcase_10 AC 319 ms
15,404 KB
testcase_11 AC 329 ms
15,280 KB
testcase_12 AC 326 ms
15,212 KB
testcase_13 AC 327 ms
15,416 KB
testcase_14 AC 326 ms
15,260 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

def solve(xs, ac)
  return ac if xs.size == 0
  ys = xs.clone
  y = ys[0]
  ys.delete_at 0
  ans = 0
  ys.size.times do |i|
    zs = ys.clone
    z = ys[i]
    zs.delete_at i
    ans = [ans, solve(zs, (y ^ z) + ac)].max
  end
  ans
end
_ = gets.to_i
xs = gets.split.map(&:to_i)
p solve(xs, 0)
0