結果

問題 No.33 アメーバがたくさん
ユーザー 👑 obakyanobakyan
提出日時 2020-04-27 22:42:42
言語 Lua
(LuaJit 2.1.1696795921)
結果
AC  
実行時間 1 ms / 5,000 ms
コード長 658 bytes
コンパイル時間 288 ms
コンパイル使用メモリ 5,376 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-08-14 14:48:33
合計ジャッジ時間 948 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 1 ms
4,380 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 1 ms
4,380 KB
testcase_08 AC 1 ms
4,380 KB
testcase_09 AC 1 ms
4,380 KB
testcase_10 AC 1 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

local mmi, mma = math.min, math.max
local mfl, mce = math.floor, math.ceil
local n, d, t = io.read("*n", "*n", "*n")
local rem = {}
local bias = 1000000007
for i = 1, n do
  local x = bias + io.read("*n")
  local r = x % d
  if not rem[r] then rem[r] = {} end
  local z = mfl(x / d)
  table.insert(rem[r], {z - t, z + t})
end
local ret = 0
for _u, tbl in pairs(rem) do
  table.sort(tbl, function(a, b) return a[1] < b[1] end)
  ret = ret + tbl[1][2] - tbl[1][1] + 1
  local right = tbl[1][2]
  for i = 2, #tbl do
    local l, r = tbl[i][1], tbl[i][2]
    l = mma(l, right + 1)
    ret = ret + mma(0, r - l + 1)
    right = mma(right, r)
  end
end
print(ret)
0