結果
問題 |
No.1534 おなかがいたい
|
ユーザー |
![]() |
提出日時 | 2021-06-07 12:30:06 |
言語 | Ruby (3.4.1) |
結果 |
TLE
|
実行時間 | - |
コード長 | 376 bytes |
コンパイル時間 | 102 ms |
コンパイル使用メモリ | 7,552 KB |
実行使用メモリ | 94,344 KB |
最終ジャッジ日時 | 2024-11-24 15:04:23 |
合計ジャッジ時間 | 19,229 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 14 TLE * 5 |
コンパイルメッセージ
Main.rb:18: warning: ambiguous first argument; put parentheses or a space even after `-' operator Main.rb:25: warning: ambiguous first argument; put parentheses or a space even after `-' operator Main.rb:2: warning: assigned but unused variable - ans Syntax OK
ソースコード
S = gets.chomp ans = 0 stack = [] pon_cnt = 0 pon_arr = %w(p o n) pain_arr = %w(p a i n) S.each_char do |s| stack << s if s == 'n' && stack.size >= 3 pon_cnt += 1 if stack[-3..-1] == pon_arr if stack.size >= 4 && stack[-4..-1] == pain_arr if pon_cnt >= 2 puts pon_cnt - 1 else puts -1 end exit end end end puts -1