結果
問題 |
No.1534 おなかがいたい
|
ユーザー |
![]() |
提出日時 | 2021-06-09 21:00:47 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
AC
|
実行時間 | 106 ms / 2,000 ms |
コード長 | 633 bytes |
コンパイル時間 | 305 ms |
コンパイル使用メモリ | 12,416 KB |
実行使用メモリ | 12,524 KB |
最終ジャッジ日時 | 2024-11-28 21:26:05 |
合計ジャッジ時間 | 1,993 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 19 |
ソースコード
def main(): s = str(input()) n = len(s) stack = [] Flag = 0 for i in range(n): if i+4 <= n and s[i:i+4] == "pain": Flag = 1 break else: stack.append(s[i]) #print(stack) if Flag == 0: print(-1);exit() ans = 0 while len(stack) >= 3: if stack[-3] == "p" and stack[-2] == "o" and stack[-1] == "n": ans += 1 stack.pop() stack.pop() stack.pop() else: stack.pop() if ans >= 2: print(ans-1) else: print(-1) if __name__ == '__main__': main()