結果

問題 No.513 宝探し2
ユーザー cympfhcympfh
提出日時 2017-05-05 22:36:42
言語 Ruby
(3.3.0)
結果
WA  
実行時間 -
コード長 553 bytes
コンパイル時間 379 ms
コンパイル使用メモリ 11,212 KB
実行使用メモリ 31,508 KB
平均クエリ数 97.00
最終ジャッジ日時 2023-09-23 13:19:45
合計ジャッジ時間 4,053 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

M = 100000

def get(x, y)

  x = [M, [0, x].max].min
  y = [M, [0, y].max].min

  puts "#{x} #{y}"
  STDOUT.flush
  d = gets.to_i
  return d
end

y = M / 2
left = 0
right = M

while right - left > 2

  p [left, right]

  x1 = (left + left + right) / 3
  x2 = (left + right + right) / 3
  d1 = get(x1, y)
  d2 = get(x2, y)
  if d1 < d2
    right = x2
  else
    left = x1
  end

end

mn_d = M * M
mn_x = left

((left - 5)..(left + 5)).each do |x|
  d = get(x, y)
  if d < mn_d
    mn_d = d
    mn_x = x
  end
end

get(mn_x, y + mn_d)
get(mn_x, y - mn_d)
0