結果

問題 No.1159 Sashiming String
ユーザー siman
提出日時 2021-01-15 19:40:24
言語 Ruby
(3.4.1)
結果
AC  
実行時間 207 ms / 2,000 ms
コード長 210 bytes
コンパイル時間 46 ms
コンパイル使用メモリ 7,552 KB
実行使用メモリ 12,544 KB
最終ジャッジ日時 2024-11-26 11:20:21
合計ジャッジ時間 2,880 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 12
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

S = gets.chomp

s_cnt = 0
ing_cnt = 0
ans = 0

S.each_char.with_index do |s, idx|
  if s == 'S'
    s_cnt += 1
  elsif idx >= 2 && S[idx - 2..idx] == 'ing'
    ing_cnt += 1
    ans += s_cnt
  end
end

puts ans
0