結果

問題 No.281 門松と魔法(1)
ユーザー 👑 obakyanobakyan
提出日時 2019-06-03 11:32:46
言語 Lua
(LuaJit 2.1.1696795921)
結果
WA  
実行時間 -
コード長 943 bytes
コンパイル時間 66 ms
コンパイル使用メモリ 5,336 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-10-17 23:16:27
合計ジャッジ時間 2,790 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 1 ms
4,348 KB
testcase_03 AC 1 ms
4,348 KB
testcase_04 WA -
testcase_05 AC 2 ms
4,348 KB
testcase_06 AC 2 ms
4,348 KB
testcase_07 AC 1 ms
4,348 KB
testcase_08 AC 1 ms
4,348 KB
testcase_09 AC 2 ms
4,348 KB
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 AC 1 ms
4,348 KB
testcase_15 AC 1 ms
4,348 KB
testcase_16 AC 1 ms
4,348 KB
testcase_17 AC 2 ms
4,348 KB
testcase_18 AC 1 ms
4,348 KB
testcase_19 AC 1 ms
4,348 KB
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 AC 1 ms
4,348 KB
testcase_24 WA -
testcase_25 AC 1 ms
4,348 KB
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 AC 1 ms
4,348 KB
testcase_30 AC 2 ms
4,348 KB
testcase_31 WA -
testcase_32 AC 1 ms
4,348 KB
testcase_33 AC 1 ms
4,348 KB
testcase_34 WA -
testcase_35 AC 1 ms
4,348 KB
testcase_36 WA -
testcase_37 AC 2 ms
4,348 KB
testcase_38 AC 1 ms
4,348 KB
testcase_39 AC 2 ms
4,348 KB
testcase_40 AC 2 ms
4,348 KB
testcase_41 AC 1 ms
4,348 KB
testcase_42 AC 2 ms
4,348 KB
testcase_43 WA -
testcase_44 AC 1 ms
4,348 KB
testcase_45 WA -
testcase_46 WA -
testcase_47 WA -
testcase_48 WA -
testcase_49 WA -
testcase_50 WA -
testcase_51 AC 2 ms
4,348 KB
testcase_52 WA -
testcase_53 WA -
testcase_54 WA -
testcase_55 WA -
testcase_56 AC 2 ms
4,348 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

local mmi, mma, mce = math.min, math.max, math.ceil
local d, h1, h2, h3 = io.read("*n", "*n", "*n", "*n")

local function getcount(d, min, mid, max)
  local cnt = 0
  if max <= mid then
    local midcnt = mce((mid - max + 1) / d)
    mid = mid - midcnt * d
    cnt = cnt + midcnt
  end
  if mid <= 0 then
    return -1
  end
  if mid <= min then
    local mincnt = mce((min - mid + 1) / d)
    min = min - mincnt * d
    cnt = cnt + mincnt
  end
  if min <= 0 then
    return -1
  end
  return cnt
end

local ret = -1
local a = getcount(d, h1, h3, h2)
if 0 <= a then
  if ret == -1 then ret = a else ret = mmi(ret, a) end
end
a = getcount(d, h3, h1, h2)
if 0 <= a then
  if ret == -1 then ret = a else ret = mmi(ret, a) end
end
a = getcount(d, h2, h1, h3)
if 0 <= a then
  if ret == -1 then ret = a else ret = mmi(ret, a) end
end
a = getcount(d, h2, h3, h1)
if 0 <= a then
  if ret == -1 then ret = a else ret = mmi(ret, a) end
end
print(ret)
0