結果
問題 |
No.345 最小チワワ問題
|
ユーザー |
![]() |
提出日時 | 2020-03-29 21:53:05 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
RE
|
実行時間 | - |
コード長 | 378 bytes |
コンパイル時間 | 204 ms |
コンパイル使用メモリ | 12,416 KB |
実行使用メモリ | 11,520 KB |
最終ジャッジ日時 | 2025-01-02 15:50:10 |
合計ジャッジ時間 | 2,382 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 27 RE * 2 |
ソースコード
import sys input=lambda: sys.stdin.readline().rstrip() S=input() n=len(S) C=[] W=[] import bisect for i in range(n): if S[i]=="c": C.append(i) if S[i]=="w": W.append(i) ans=float("inf") for i in range(len(W)-1): w1,w2=W[i],W[i+1] if w1<C[0]: continue else: c=C[bisect.bisect_left(C,w1)-1] ans=min(ans,w2-c+1) print(-1 if ans==float("inf") else ans)