結果

問題 No.67 よくある棒を切る問題 (1)
ユーザー 👑 obakyanobakyan
提出日時 2019-06-09 15:38:57
言語 Lua
(LuaJit 2.1.1696795921)
結果
AC  
実行時間 239 ms / 5,000 ms
コード長 723 bytes
コンパイル時間 336 ms
コンパイル使用メモリ 6,688 KB
実行使用メモリ 11,852 KB
最終ジャッジ日時 2024-04-26 00:42:05
合計ジャッジ時間 6,601 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 194 ms
8,960 KB
testcase_01 AC 2 ms
6,948 KB
testcase_02 AC 86 ms
6,944 KB
testcase_03 AC 164 ms
10,120 KB
testcase_04 AC 212 ms
9,024 KB
testcase_05 AC 215 ms
9,020 KB
testcase_06 AC 212 ms
9,016 KB
testcase_07 AC 233 ms
11,728 KB
testcase_08 AC 232 ms
11,848 KB
testcase_09 AC 232 ms
11,716 KB
testcase_10 AC 197 ms
9,004 KB
testcase_11 AC 205 ms
9,112 KB
testcase_12 AC 187 ms
9,020 KB
testcase_13 AC 214 ms
11,344 KB
testcase_14 AC 223 ms
11,628 KB
testcase_15 AC 195 ms
10,356 KB
testcase_16 AC 215 ms
9,020 KB
testcase_17 AC 215 ms
9,016 KB
testcase_18 AC 217 ms
9,020 KB
testcase_19 AC 239 ms
11,720 KB
testcase_20 AC 235 ms
11,848 KB
testcase_21 AC 231 ms
11,852 KB
testcase_22 AC 198 ms
9,012 KB
testcase_23 AC 210 ms
9,008 KB
testcase_24 AC 1 ms
6,940 KB
testcase_25 AC 6 ms
6,940 KB
testcase_26 AC 3 ms
6,944 KB
testcase_27 AC 2 ms
6,944 KB
testcase_28 AC 37 ms
6,940 KB
testcase_29 AC 20 ms
6,944 KB
testcase_30 AC 6 ms
6,940 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