結果

問題 No.253 ロウソクの長さ
ユーザー simansiman
提出日時 2021-01-11 15:58:07
言語 Ruby
(3.3.0)
結果
WA  
実行時間 -
コード長 419 bytes
コンパイル時間 66 ms
コンパイル使用メモリ 11,484 KB
実行使用メモリ 31,508 KB
平均クエリ数 21.72
最終ジャッジ日時 2023-09-24 09:40:51
合計ジャッジ時間 6,105 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 108 ms
30,724 KB
testcase_01 AC 109 ms
30,948 KB
testcase_02 AC 103 ms
31,424 KB
testcase_03 AC 107 ms
31,232 KB
testcase_04 AC 105 ms
31,004 KB
testcase_05 AC 106 ms
31,388 KB
testcase_06 AC 106 ms
31,400 KB
testcase_07 AC 105 ms
31,236 KB
testcase_08 AC 104 ms
31,216 KB
testcase_09 AC 101 ms
30,704 KB
testcase_10 AC 102 ms
30,924 KB
testcase_11 AC 102 ms
30,872 KB
testcase_12 AC 103 ms
30,580 KB
testcase_13 AC 102 ms
31,204 KB
testcase_14 AC 104 ms
31,060 KB
testcase_15 AC 102 ms
31,072 KB
testcase_16 AC 102 ms
30,900 KB
testcase_17 WA -
testcase_18 AC 105 ms
31,048 KB
testcase_19 AC 103 ms
31,508 KB
testcase_20 AC 103 ms
31,408 KB
testcase_21 AC 102 ms
31,012 KB
testcase_22 AC 108 ms
31,212 KB
testcase_23 AC 108 ms
31,308 KB
testcase_24 AC 107 ms
30,672 KB
testcase_25 AC 108 ms
30,808 KB
testcase_26 AC 101 ms
30,752 KB
testcase_27 AC 105 ms
30,968 KB
testcase_28 AC 102 ms
31,348 KB
testcase_29 AC 102 ms
31,372 KB
testcase_30 AC 105 ms
30,924 KB
testcase_31 AC 108 ms
31,128 KB
testcase_32 AC 108 ms
31,208 KB
testcase_33 AC 106 ms
31,204 KB
testcase_34 AC 107 ms
30,756 KB
testcase_35 AC 104 ms
30,872 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

def query(y)
  STDOUT.puts("? #{y}")
  STDOUT.flush
  gets.chomp.to_i
end

res = query(100)

if res == 0
  puts 100
  exit
elsif res < 0
  ok = 0
  ng = 100
else
  ok = 100
  ng = 10 ** 9 + 1
end

99.times do |i|
  y = (ok + ng) / 2
  res = query(y)

  if res == 0
    STDOUT.puts("! #{y + i + 1}")
    STDOUT.flush
    break
  elsif res < 0
    ng = y
    ok = [0, ok - 1].max
  else
    ok = [0, y - 1].max
  end
end
0