結果

問題 No.3 ビットすごろく
ユーザー gemmarogemmaro
提出日時 2020-04-28 22:51:01
言語 Ruby
(3.3.0)
結果
TLE  
実行時間 -
コード長 374 bytes
コンパイル時間 255 ms
コンパイル使用メモリ 11,252 KB
実行使用メモリ 91,592 KB
最終ジャッジ日時 2023-08-17 03:05:29
合計ジャッジ時間 25,247 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 83 ms
15,148 KB
testcase_01 AC 83 ms
15,224 KB
testcase_02 AC 83 ms
15,284 KB
testcase_03 AC 1,144 ms
80,696 KB
testcase_04 AC 97 ms
16,708 KB
testcase_05 TLE -
testcase_06 AC 1,355 ms
86,384 KB
testcase_07 AC 135 ms
21,252 KB
testcase_08 AC 388 ms
48,360 KB
testcase_09 AC 849 ms
80,216 KB
testcase_10 AC 1,106 ms
88,180 KB
testcase_11 AC 743 ms
68,588 KB
testcase_12 AC 4,874 ms
91,592 KB
testcase_13 AC 824 ms
74,856 KB
testcase_14 TLE -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

# frozen_string_literal: true

def solve # rubocop:todo Metrics/MethodLength
  p = [1]

  (1..N).each do |i|
    n = []
    p.each do |x|
      y = x + C[x]
      return i + 1 if y == N

      n << y if y < N

      z = x - C[x]
      n << z if z > 1
    end
    p = n.uniq
  end

  -1
end

N = gets.to_i

C = (0..N).map { _1.digits(2).count(1) }
RESULT = solve

puts RESULT
0