結果

問題 No.246 質問と回答
ユーザー gemmarogemmaro
提出日時 2020-05-25 09:24:04
言語 Ruby
(3.3.0)
結果
AC  
実行時間 114 ms / 2,000 ms
コード長 272 bytes
コンパイル時間 360 ms
コンパイル使用メモリ 11,428 KB
実行使用メモリ 31,464 KB
平均クエリ数 31.00
最終ジャッジ日時 2023-09-23 20:34:57
合計ジャッジ時間 5,791 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 114 ms
30,924 KB
testcase_01 AC 108 ms
30,676 KB
testcase_02 AC 110 ms
31,276 KB
testcase_03 AC 107 ms
30,984 KB
testcase_04 AC 109 ms
31,288 KB
testcase_05 AC 106 ms
31,308 KB
testcase_06 AC 108 ms
30,896 KB
testcase_07 AC 109 ms
31,292 KB
testcase_08 AC 111 ms
30,724 KB
testcase_09 AC 110 ms
30,984 KB
testcase_10 AC 108 ms
30,936 KB
testcase_11 AC 114 ms
30,968 KB
testcase_12 AC 108 ms
30,852 KB
testcase_13 AC 103 ms
30,972 KB
testcase_14 AC 107 ms
31,004 KB
testcase_15 AC 110 ms
31,112 KB
testcase_16 AC 106 ms
30,680 KB
testcase_17 AC 108 ms
31,052 KB
testcase_18 AC 109 ms
31,464 KB
testcase_19 AC 111 ms
31,268 KB
testcase_20 AC 107 ms
31,152 KB
testcase_21 AC 107 ms
30,820 KB
testcase_22 AC 107 ms
31,084 KB
testcase_23 AC 107 ms
31,232 KB
testcase_24 AC 108 ms
30,816 KB
testcase_25 AC 107 ms
31,352 KB
testcase_26 AC 105 ms
30,976 KB
testcase_27 AC 107 ms
30,884 KB
testcase_28 AC 105 ms
31,232 KB
testcase_29 AC 107 ms
31,064 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

# frozen_string_literal: true

left = 1
right = 10**9

loop do
  if left == right
    puts %(! #{left})
    STDOUT.flush
    exit
  end

  center = (left + right) / 2 + 1
  puts %(? #{center})
  STDOUT.flush
  gets.chomp == '1' ? (left = center) : (right = center - 1)
end
0