結果
問題 | No.345 最小チワワ問題 |
ユーザー |
![]() |
提出日時 | 2019-01-27 16:38:11 |
言語 | Ruby (3.4.1) |
結果 |
AC
|
実行時間 | 97 ms / 2,000 ms |
コード長 | 620 bytes |
コンパイル時間 | 57 ms |
コンパイル使用メモリ | 7,552 KB |
実行使用メモリ | 12,416 KB |
最終ジャッジ日時 | 2024-10-01 05:11:38 |
合計ジャッジ時間 | 3,873 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 29 |
コンパイルメッセージ
Syntax OK
ソースコード
strs = gets.chomp.scan(/c.*w.*w/)if strs.length == 0puts "-1"elsechars = strs[0].charsmax = chars.length - 1w1,w2 = false,falseres = []count = 10.step(max) do |i|next if chars[i] != "c"(i + 1).step(max) do |j|count += 1if chars[j] == "w" and not w1w1 = trueelsif chars[j] == "w" and w1w2 = trueendif w1 and w2res << countbreakendendcount = 1w1,w2 = false , falseendputs res.minend