結果

問題 No.1534 おなかがいたい
ユーザー 👑 obakyan
提出日時 2021-06-08 22:14:12
言語 Lua
(LuaJit 2.1.1734355927)
結果
AC  
実行時間 5 ms / 2,000 ms
コード長 227 bytes
コンパイル時間 237 ms
コンパイル使用メモリ 5,248 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-11-27 05:16:57
合計ジャッジ時間 831 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 19
権限があれば一括ダウンロードができます

ソースコード

diff #

s = io.read()
p = s:find("pain")
if not p then print(-1) os.exit() end
c = 0
a = 1
while true do
  a = s:find("pon", a)
  if a and a < p then
    c = c + 1
    a = a + 1
  else
    break
  end
end
print(2 <= c and c - 1 or -1)
0