結果

問題 No.345 最小チワワ問題
ユーザー utsumidaisuke
提出日時 2018-12-07 17:06:59
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
AC  
実行時間 33 ms / 2,000 ms
コード長 463 bytes
コンパイル時間 311 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 10,752 KB
最終ジャッジ日時 2024-10-01 05:10:32
合計ジャッジ時間 2,143 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 29
権限があれば一括ダウンロードができます

ソースコード

diff #

w = list(input())

c_idx = [n for n, i in enumerate(w) if i == 'c']
w_idx = [n for n, i in enumerate(w) if i == 'w']

if w.count('c') == 0 or w.count('w') < 2:
    print(-1)

elif w[c_idx[0]:].count('w') < 2:
    print(-1)
else:
    ls = []
    for i in c_idx:
        if len([j for j in w_idx if j > i]) < 2:
            break
        else:
            wls = [j for j in w_idx if j > i]
            ls.append(wls[1] - i + 1)
                  
    print(min(ls))
0