結果

問題 No.345 最小チワワ問題
ユーザー harhogefooharhogefoo
提出日時 2016-10-14 09:35:47
言語 Ruby
(3.4.1)
結果
WA  
実行時間 -
コード長 257 bytes
コンパイル時間 65 ms
コンパイル使用メモリ 7,424 KB
実行使用メモリ 12,416 KB
最終ジャッジ日時 2024-11-22 05:58:26
合計ジャッジ時間 4,128 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 15 WA * 14
権限があれば一括ダウンロードができます
コンパイルメッセージ
Main.rb:17: warning: ambiguous first argument; put parentheses or a space even after `-' operator
Syntax OK

ソースコード

diff #

s = gets.chomp

count = 0
is_c = false
w_count = 0
s.each_char do |c|
  is_c = true if c == 'c'
  w_count += 1 if is_c and c == 'w'

  if is_c and w_count <= 2
    count += 1
  end
  break if w_count == 2
end

if w_count != 2
  puts -1
else
  puts count
end
0