結果
問題 | No.1159 Sashiming String |
ユーザー |
👑 |
提出日時 | 2021-05-24 15:39:57 |
言語 | Lua (LuaJit 2.1.1696795921) |
結果 |
AC
|
実行時間 | 6 ms / 2,000 ms |
コード長 | 687 bytes |
コンパイル時間 | 45 ms |
コンパイル使用メモリ | 6,692 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2024-10-12 23:53:40 |
合計ジャッジ時間 | 1,050 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 1 ms
6,816 KB |
testcase_01 | AC | 2 ms
6,816 KB |
testcase_02 | AC | 2 ms
6,816 KB |
testcase_03 | AC | 2 ms
6,820 KB |
testcase_04 | AC | 3 ms
6,820 KB |
testcase_05 | AC | 3 ms
6,820 KB |
testcase_06 | AC | 2 ms
6,816 KB |
testcase_07 | AC | 3 ms
6,816 KB |
testcase_08 | AC | 4 ms
6,816 KB |
testcase_09 | AC | 6 ms
6,820 KB |
testcase_10 | AC | 2 ms
6,816 KB |
testcase_11 | AC | 2 ms
6,820 KB |
testcase_12 | AC | 1 ms
6,816 KB |
testcase_13 | AC | 1 ms
6,816 KB |
ソースコード
local mfl = math.floor local function comp(a, b) return a < b end local function lower_bound(ary, x) local num = #ary if num == 0 then return 1 end if not comp(ary[1], x) then return 1 end if comp(ary[num], x) then return num + 1 end local min, max = 1, num while 1 < max - min do local mid = mfl((min + max) / 2) if comp(ary[mid], x) then min = mid else max = mid end end return max end local s = io.read() local a = {} local z = s:find("S") while z do table.insert(a, z) z = s:find("S", z + 1) end local b = {} z = s:find("ing") local ret = 0 while z do ret = ret + lower_bound(a, z) - 1 z = s:find("ing", z + 1) end print(ret)