結果

問題 No.67 よくある棒を切る問題 (1)
ユーザー 👑 obakyanobakyan
提出日時 2019-06-09 15:36:58
言語 Lua
(LuaJit 2.1.1696795921)
結果
TLE  
実行時間 -
コード長 703 bytes
コンパイル時間 122 ms
コンパイル使用メモリ 4,900 KB
実行使用メモリ 22,360 KB
最終ジャッジ日時 2023-07-28 11:25:50
合計ジャッジ時間 8,661 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 48 ms
22,360 KB
testcase_01 AC 1 ms
4,384 KB
testcase_02 AC 37 ms
7,220 KB
testcase_03 AC 80 ms
11,956 KB
testcase_04 AC 88 ms
10,072 KB
testcase_05 AC 88 ms
10,112 KB
testcase_06 AC 88 ms
10,052 KB
testcase_07 AC 105 ms
13,796 KB
testcase_08 AC 100 ms
13,832 KB
testcase_09 TLE -
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-10 < max - min do
  local mid = (min + max) / 2
  if check(mid) then
    min = mid
  else
    max = mid
  end
end
print(string.format("%.11f", (min + max) / 2))
0