結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 109 ms
31,108 KB
testcase_01 AC 102 ms
30,752 KB
testcase_02 AC 101 ms
31,368 KB
testcase_03 AC 101 ms
31,128 KB
testcase_04 AC 102 ms
30,604 KB
testcase_05 AC 102 ms
31,088 KB
testcase_06 AC 102 ms
31,364 KB
testcase_07 AC 103 ms
31,320 KB
testcase_08 AC 105 ms
31,048 KB
testcase_09 AC 103 ms
30,860 KB
testcase_10 AC 106 ms
30,720 KB
testcase_11 AC 103 ms
31,136 KB
testcase_12 AC 103 ms
30,852 KB
testcase_13 AC 102 ms
31,272 KB
testcase_14 AC 103 ms
30,896 KB
testcase_15 AC 104 ms
31,148 KB
testcase_16 AC 101 ms
31,248 KB
testcase_17 WA -
testcase_18 AC 104 ms
31,364 KB
testcase_19 AC 105 ms
30,888 KB
testcase_20 AC 104 ms
31,236 KB
testcase_21 AC 101 ms
30,968 KB
testcase_22 AC 101 ms
30,796 KB
testcase_23 AC 101 ms
30,908 KB
testcase_24 AC 99 ms
30,840 KB
testcase_25 AC 101 ms
31,036 KB
testcase_26 AC 98 ms
31,032 KB
testcase_27 AC 99 ms
30,812 KB
testcase_28 AC 100 ms
31,172 KB
testcase_29 AC 100 ms
31,108 KB
testcase_30 AC 102 ms
31,108 KB
testcase_31 AC 101 ms
30,876 KB
testcase_32 AC 101 ms
30,588 KB
testcase_33 AC 101 ms
31,004 KB
testcase_34 AC 101 ms
31,004 KB
testcase_35 AC 103 ms
31,120 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 = 101
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