結果
問題 | 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 == 0 puts "-1" else chars = strs[0].chars max = chars.length - 1 w1,w2 = false,false res = [] count = 1 0.step(max) do |i| next if chars[i] != "c" (i + 1).step(max) do |j| count += 1 if chars[j] == "w" and not w1 w1 = true elsif chars[j] == "w" and w1 w2 = true end if w1 and w2 res << count break end end count = 1 w1,w2 = false , false end puts res.min end