結果

問題 No.1534 おなかがいたい
ユーザー lloyz
提出日時 2021-12-21 22:57:45
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
AC  
実行時間 182 ms / 2,000 ms
コード長 310 bytes
コンパイル時間 309 ms
コンパイル使用メモリ 12,416 KB
実行使用メモリ 11,136 KB
最終ジャッジ日時 2024-09-15 15:40:39
合計ジャッジ時間 2,977 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 19
権限があれば一括ダウンロードができます

ソースコード

diff #

S = input()
n = len(S)

cnt = 0
flag = False
for i in range(n):
    if i <= n - 3:
        if S[i:i + 3] == 'pon':
            cnt += 1
    if i <= n - 4:
        if S[i:i + 4] == 'pain':
            flag = True
            break

if cnt >= 2 and flag:
    print(cnt - 1)
else:
    print(-1)
0