結果

問題 No.871 かえるのうた
ユーザー 👑 obakyanobakyan
提出日時 2019-08-30 21:42:06
言語 Lua
(LuaJit 2.1.1696795921)
結果
AC  
実行時間 103 ms / 2,000 ms
コード長 559 bytes
コンパイル時間 152 ms
コンパイル使用メモリ 5,300 KB
実行使用メモリ 11,616 KB
最終ジャッジ日時 2023-08-20 09:16:46
合計ジャッジ時間 3,643 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 1 ms
4,380 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 4 ms
4,380 KB
testcase_09 AC 4 ms
4,380 KB
testcase_10 AC 2 ms
4,380 KB
testcase_11 AC 2 ms
4,376 KB
testcase_12 AC 16 ms
4,376 KB
testcase_13 AC 5 ms
4,376 KB
testcase_14 AC 84 ms
10,544 KB
testcase_15 AC 84 ms
10,580 KB
testcase_16 AC 103 ms
11,616 KB
testcase_17 AC 79 ms
10,184 KB
testcase_18 AC 16 ms
4,380 KB
testcase_19 AC 86 ms
10,604 KB
testcase_20 AC 9 ms
4,380 KB
testcase_21 AC 34 ms
5,716 KB
testcase_22 AC 1 ms
4,380 KB
testcase_23 AC 1 ms
4,376 KB
testcase_24 AC 1 ms
4,380 KB
testcase_25 AC 3 ms
4,380 KB
testcase_26 AC 10 ms
4,376 KB
testcase_27 AC 13 ms
4,384 KB
testcase_28 AC 1 ms
4,376 KB
testcase_29 AC 47 ms
7,240 KB
testcase_30 AC 74 ms
10,008 KB
testcase_31 AC 3 ms
4,380 KB
testcase_32 AC 60 ms
8,712 KB
testcase_33 AC 78 ms
10,668 KB
testcase_34 AC 21 ms
4,596 KB
testcase_35 AC 48 ms
7,052 KB
testcase_36 AC 64 ms
9,400 KB
testcase_37 AC 39 ms
6,112 KB
testcase_38 AC 90 ms
10,704 KB
testcase_39 AC 87 ms
10,496 KB
testcase_40 AC 50 ms
8,684 KB
testcase_41 AC 1 ms
4,376 KB
testcase_42 AC 59 ms
9,572 KB
testcase_43 AC 1 ms
4,380 KB
testcase_44 AC 1 ms
4,380 KB
testcase_45 AC 4 ms
4,376 KB
testcase_46 AC 2 ms
4,380 KB
testcase_47 AC 1 ms
4,380 KB
testcase_48 AC 1 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

local n, k = io.read("*n", "*n")
local x, a = {}, {}
for i = 1, n do
  x[i] = 0LL + io.read("*n")
end
for i = 1, n do
  a[i] = 0LL + io.read("*n")
end

local tasks = {k}
local l, r = k, k
while 0 < #tasks do
  local idx = tasks[#tasks]
  table.remove(tasks)
  for ir = r + 1, n do
    if x[ir] <= x[idx] + a[idx] then
      table.insert(tasks, ir)
      r = ir
    else
      break
    end
  end
  for il = l - 1, 1, -1 do
    if x[idx] - a[idx] <= x[il] then
      table.insert(tasks, il)
      l = il
    else
      break
    end
  end
end
print(r - l + 1)
0