結果

問題 No.67 よくある棒を切る問題 (1)
ユーザー 👑 obakyanobakyan
提出日時 2019-06-09 15:35:17
言語 Lua
(LuaJit 2.1.1696795921)
結果
TLE  
実行時間 -
コード長 703 bytes
コンパイル時間 114 ms
コンパイル使用メモリ 5,376 KB
実行使用メモリ 15,284 KB
最終ジャッジ日時 2024-04-15 20:06:46
合計ジャッジ時間 7,008 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 41 ms
15,284 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 TLE -
testcase_03 -- -
testcase_04 -- -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

local mmi, mma, mfl = math.min, math.max, math.floor
local n = io.read("*n", "*l")
local str = io.read()
local ls = {}
local lmin, lmax = 0, 0
local ti = 1
for v in str:gmatch("%d+") do
  local num = tonumber(v)
  if lmax == 0 then
    lmin, lmax = num, num
  else
    lmin, lmax = mmi(lmin, num), mma(lmax, num)
  end
  ls[ti] = num
  ti = ti + 1
end
local k = io.read("*n")

local function check(tgt)
  local cnt = 0
  for i = 1, n do
    cnt = cnt + mfl(ls[i] / tgt)
  end
  return k <= cnt
end

local min, max = lmin / k, lmax
while 1.0e-12 < max - min do
  local mid = (min + max) / 2
  if check(mid) then
    min = mid
  else
    max = mid
  end
end
print(string.format("%.15f", (min + max) / 2))
0