結果

問題 No.1535 五七五
ユーザー 👑 obakyanobakyan
提出日時 2021-06-19 19:25:15
言語 Lua
(LuaJit 2.1.1696795921)
結果
AC  
実行時間 316 ms / 2,000 ms
コード長 737 bytes
コンパイル時間 318 ms
コンパイル使用メモリ 5,340 KB
実行使用メモリ 35,000 KB
最終ジャッジ日時 2023-09-05 01:10:44
合計ジャッジ時間 5,741 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 132 ms
7,844 KB
testcase_05 AC 316 ms
34,900 KB
testcase_06 AC 312 ms
35,000 KB
testcase_07 AC 1 ms
4,376 KB
testcase_08 AC 1 ms
4,380 KB
testcase_09 AC 1 ms
4,380 KB
testcase_10 AC 1 ms
4,376 KB
testcase_11 AC 1 ms
4,376 KB
testcase_12 AC 2 ms
4,380 KB
testcase_13 AC 1 ms
4,380 KB
testcase_14 AC 1 ms
4,376 KB
testcase_15 AC 1 ms
4,380 KB
testcase_16 AC 1 ms
4,376 KB
testcase_17 AC 1 ms
4,384 KB
testcase_18 AC 271 ms
19,956 KB
testcase_19 AC 276 ms
19,884 KB
testcase_20 AC 273 ms
19,964 KB
testcase_21 AC 265 ms
19,860 KB
testcase_22 AC 261 ms
19,956 KB
testcase_23 AC 277 ms
19,856 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

local n = io.read("*n")
local a, b, c = io.read("*n", "*n", "*n", "*l")
local s = io.read()
local t = {}
for w in s:gmatch("%w+") do
  table.insert(t, #w)
end
for i = 2, n do
  t[i] = t[i - 1] + t[i]
end
local ret = 0
local offset = 0
local ap, bp, cp = 1, 1, 1
for i = 1, n do
  while ap <= n and t[ap] < offset + a do
    ap = ap + 1
  end
  if n < ap then
    bp = ap
  else
    while bp <= n and t[bp] < t[ap] + b do
      bp = bp + 1
    end
  end
  if n < bp then
    cp = bp
  else
    while cp <= n and t[cp] < t[bp] + c do
      cp = cp + 1
    end
  end
  if ap <= n and bp <= n and cp <= n
  and t[cp] - t[bp] == c
  and t[bp] - t[ap] == b
  and t[ap] - offset == a then
    ret = ret + 1
  end
  offset = t[i]
end
print(ret)
0