結果

問題 No.345 最小チワワ問題
ユーザー maimai
提出日時 2016-02-26 22:32:13
言語 Ruby
(3.3.0)
結果
WA  
実行時間 -
コード長 246 bytes
コンパイル時間 307 ms
コンパイル使用メモリ 11,888 KB
実行使用メモリ 16,084 KB
最終ジャッジ日時 2023-10-23 20:31:18
合計ジャッジ時間 3,904 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 86 ms
16,080 KB
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 AC 86 ms
16,080 KB
testcase_07 AC 81 ms
16,080 KB
testcase_08 AC 82 ms
16,080 KB
testcase_09 AC 83 ms
16,080 KB
testcase_10 AC 83 ms
16,080 KB
testcase_11 AC 83 ms
16,080 KB
testcase_12 AC 84 ms
16,080 KB
testcase_13 AC 83 ms
16,080 KB
testcase_14 AC 83 ms
16,080 KB
testcase_15 WA -
testcase_16 AC 82 ms
16,080 KB
testcase_17 WA -
testcase_18 WA -
testcase_19 AC 82 ms
16,080 KB
testcase_20 AC 83 ms
16,080 KB
testcase_21 AC 83 ms
16,084 KB
testcase_22 AC 84 ms
16,080 KB
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 AC 86 ms
16,080 KB
testcase_29 WA -
testcase_30 WA -
testcase_31 AC 83 ms
16,080 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

#gets.split(" ").map!(&:to_i)

i=0
w=0
c=nil
m=nil
gets.chars{|e|
    i+=1
    next if e!="c"&&e!="w"
    next if (!c&&e=="w")
    c=i if e=="c"
    if e=="w"
        w+=1
        next if w<2
        m=i-c+1 if !m||i-c+1<m
    end
}
p !m ? -1 : m
0