結果
問題 |
No.1534 おなかがいたい
|
ユーザー |
![]() |
提出日時 | 2021-06-09 20:59:08 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
WA
|
実行時間 | - |
コード長 | 632 bytes |
コンパイル時間 | 240 ms |
コンパイル使用メモリ | 12,672 KB |
実行使用メモリ | 12,780 KB |
最終ジャッジ日時 | 2024-11-28 21:24:47 |
合計ジャッジ時間 | 2,408 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 14 WA * 5 |
ソースコード
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(0) if __name__ == '__main__': main()