結果
| 問題 | No.1534 おなかがいたい |
| コンテスト | |
| ユーザー |
siman
|
| 提出日時 | 2021-06-07 12:28:50 |
| 言語 | Ruby (4.0.2) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 339 bytes |
| 記録 | |
| コンパイル時間 | 83 ms |
| コンパイル使用メモリ | 8,960 KB |
| 実行使用メモリ | 94,220 KB |
| 最終ジャッジ日時 | 2026-05-18 16:08:45 |
| 合計ジャッジ時間 | 6,033 ms |
|
ジャッジサーバーID (参考情報) |
judge2_1 / judge1_1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 10 TLE * 1 -- * 8 |
コンパイルメッセージ
Main.rb:16: warning: ambiguous first argument; put parentheses or a space even after `-` operator Main.rb:23: 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
S.each_char do |s|
stack << s
if s == 'n' && stack.size >= 3
pon_cnt += 1 if stack[-3..-1].join == 'pon'
if stack.size >= 4 && stack[-4..-1].join == 'pain'
if pon_cnt >= 2
puts pon_cnt - 1
else
puts -1
end
exit
end
end
end
puts -1
siman