結果
問題 | No.3 ビットすごろく |
ユーザー | fine |
提出日時 | 2016-03-22 01:11:35 |
言語 | Ruby (3.3.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 390 bytes |
コンパイル時間 | 100 ms |
コンパイル使用メモリ | 11,904 KB |
実行使用メモリ | 23,188 KB |
最終ジャッジ日時 | 2024-04-08 21:37:44 |
合計ジャッジ時間 | 16,243 ms |
ジャッジサーバーID (参考情報) |
judge13 / judge12 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 96 ms
16,256 KB |
testcase_01 | AC | 93 ms
16,256 KB |
testcase_02 | AC | 97 ms
16,256 KB |
testcase_03 | AC | 872 ms
16,384 KB |
testcase_04 | AC | 170 ms
16,384 KB |
testcase_05 | AC | 4,056 ms
16,640 KB |
testcase_06 | AC | 1,049 ms
16,384 KB |
testcase_07 | AC | 414 ms
16,384 KB |
testcase_08 | AC | 2,562 ms
16,512 KB |
testcase_09 | TLE | - |
testcase_10 | -- | - |
testcase_11 | -- | - |
testcase_12 | -- | - |
testcase_13 | -- | - |
testcase_14 | -- | - |
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 | -- | - |
コンパイルメッセージ
Main.rb:20: warning: ambiguous first argument; put parentheses or a space even after `-' operator Syntax OK
ソースコード
n = gets.to_i ans = Array.new(n,10000) a = [[1,1]] until a.empty? x = a.pop if ans[x[0] - 1] <= x[1] next end ans[x[0] - 1] = x[1] tmp = x[0].to_s(2).count('1') if x[0] + tmp <= n a.push([x[0] + tmp, x[1] + 1]) end if x[0] > tmp a.push([x[0] - tmp, x[1] + 1]) end end if ans[n - 1] == 10000 p -1 else p ans[n - 1] end