結果

問題 No.67 よくある棒を切る問題 (1)
ユーザー 👑 obakyanobakyan
提出日時 2019-06-09 15:38:57
言語 Lua
(LuaJit 2.1.1696795921)
結果
AC  
実行時間 239 ms / 5,000 ms
コード長 723 bytes
コンパイル時間 274 ms
コンパイル使用メモリ 5,456 KB
実行使用メモリ 13,744 KB
最終ジャッジ日時 2023-08-08 07:12:58
合計ジャッジ時間 7,085 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 203 ms
8,448 KB
testcase_01 AC 1 ms
4,384 KB
testcase_02 AC 89 ms
7,132 KB
testcase_03 AC 176 ms
11,908 KB
testcase_04 AC 223 ms
9,976 KB
testcase_05 AC 223 ms
9,984 KB
testcase_06 AC 221 ms
9,976 KB
testcase_07 AC 238 ms
13,684 KB
testcase_08 AC 238 ms
13,684 KB
testcase_09 AC 238 ms
13,680 KB
testcase_10 AC 200 ms
9,892 KB
testcase_11 AC 213 ms
9,928 KB
testcase_12 AC 196 ms
9,812 KB
testcase_13 AC 220 ms
13,588 KB
testcase_14 AC 227 ms
13,656 KB
testcase_15 AC 201 ms
12,556 KB
testcase_16 AC 223 ms
10,104 KB
testcase_17 AC 223 ms
9,960 KB
testcase_18 AC 223 ms
9,912 KB
testcase_19 AC 238 ms
13,712 KB
testcase_20 AC 236 ms
13,680 KB
testcase_21 AC 239 ms
13,744 KB
testcase_22 AC 204 ms
9,864 KB
testcase_23 AC 212 ms
9,960 KB
testcase_24 AC 1 ms
4,376 KB
testcase_25 AC 5 ms
4,380 KB
testcase_26 AC 3 ms
4,376 KB
testcase_27 AC 2 ms
4,380 KB
testcase_28 AC 37 ms
4,384 KB
testcase_29 AC 20 ms
4,376 KB
testcase_30 AC 6 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

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
for i = 1, 500 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