結果

問題 No.1170 Never Want to Walk
ユーザー 👑 obakyanobakyan
提出日時 2021-06-13 23:48:31
言語 Lua
(LuaJit 2.1.1696795921)
結果
WA  
実行時間 -
コード長 1,006 bytes
コンパイル時間 94 ms
コンパイル使用メモリ 5,356 KB
実行使用メモリ 8,744 KB
最終ジャッジ日時 2023-08-25 02:51:15
合計ジャッジ時間 7,071 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
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,380 KB
testcase_05 AC 1 ms
4,384 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 1 ms
4,384 KB
testcase_08 AC 2 ms
4,376 KB
testcase_09 AC 1 ms
4,380 KB
testcase_10 AC 1 ms
4,380 KB
testcase_11 AC 1 ms
4,380 KB
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 AC 2 ms
4,380 KB
testcase_23 AC 2 ms
4,376 KB
testcase_24 AC 2 ms
4,380 KB
testcase_25 AC 3 ms
4,376 KB
testcase_26 AC 2 ms
4,380 KB
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 AC 180 ms
8,632 KB
testcase_33 AC 166 ms
8,648 KB
testcase_34 AC 174 ms
8,544 KB
testcase_35 AC 176 ms
8,644 KB
testcase_36 AC 163 ms
8,636 KB
testcase_37 AC 176 ms
8,540 KB
testcase_38 AC 145 ms
8,468 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

local mmi, mma = math.min, math.max
local n, a, b = io.read("*n", "*n", "*n")
local x = {}
local parent = {}
local pend = {}
for i = 1, n do
  x[i] = io.read("*n")
  parent[i] = i
  pend[i] = 0
end
local left, right = 1, 0
for i = 1, n do
  while left <= n do
    if x[left] - x[i] < a then
      left = left + 1
    else
      break
    end
  end
  while right < n do
    if x[right + 1] - x[i] <= b then
      right = right + 1
    else
      break
    end
  end
  -- print(i, left, right)
  if left <= right then
    if left ~= parent[left] then
      local p = parent[left]
      parent[i] = p
      for j = pend[p] + 1, right do
        parent[j] = p
      end
      pend[p] = right
    else
      local p = parent[i]
      for j = left, right do
        parent[j] = p
      end
      pend[p] = right
    end
  end
end
-- print(table.concat(parent, " "))
local g = {}
for i = 1, n do
  local p = parent[i]
  if g[p] then g[p] = g[p] + 1 else g[p] = 1 end
end
for i = 1, n do
  print(g[parent[i]])
end
0