結果

問題 No.594 壊れた宝物発見機
ユーザー letrangerjpletrangerjp
提出日時 2017-11-11 00:02:19
言語 Ruby
(3.3.0)
結果
AC  
実行時間 212 ms / 2,000 ms
コード長 311 bytes
コンパイル時間 162 ms
コンパイル使用メモリ 11,572 KB
実行使用メモリ 31,360 KB
平均クエリ数 51.50
最終ジャッジ日時 2023-09-23 14:59:56
合計ジャッジ時間 5,956 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 212 ms
31,028 KB
testcase_01 AC 199 ms
30,868 KB
testcase_02 AC 195 ms
31,168 KB
testcase_03 AC 195 ms
31,020 KB
testcase_04 AC 196 ms
30,784 KB
testcase_05 AC 197 ms
31,164 KB
testcase_06 AC 197 ms
31,352 KB
testcase_07 AC 198 ms
30,808 KB
testcase_08 AC 196 ms
31,212 KB
testcase_09 AC 198 ms
30,732 KB
testcase_10 AC 194 ms
30,952 KB
testcase_11 AC 196 ms
31,080 KB
testcase_12 AC 198 ms
31,348 KB
testcase_13 AC 196 ms
31,188 KB
testcase_14 AC 192 ms
31,152 KB
testcase_15 AC 195 ms
30,888 KB
testcase_16 AC 193 ms
31,360 KB
testcase_17 AC 192 ms
31,296 KB
testcase_18 AC 193 ms
30,908 KB
testcase_19 AC 193 ms
31,164 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

$>.sync = true

def f(n, l=-150, r=150)
  if (l-r).abs <= 1
    return r
  end
  a = [0]*3
  a[n] = l
  puts"? #{a*' '}"
  lv = gets.to_i
  a[n] = r
  puts"? #{a*' '}"
  rv = gets.to_i
  c = (l+r)/2
  if lv > rv
    f(n, c, r)
  else
    f(n, l, c)
  end
end

x = f(0)
y = f(1)
z = f(2)
puts "! #{x} #{y} #{z}"
0