結果
問題 | No.345 最小チワワ問題 |
ユーザー |
|
提出日時 | 2019-03-16 12:13:16 |
言語 | Go (1.23.4) |
結果 |
AC
|
実行時間 | 1 ms / 2,000 ms |
コード長 | 451 bytes |
コンパイル時間 | 10,419 ms |
コンパイル使用メモリ | 237,780 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-10-01 05:14:10 |
合計ジャッジ時間 | 10,624 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 29 |
ソースコード
package mainimport ("fmt""math")func min(x, y int) int {return int(math.Min(float64(x), float64(y)))}func main(){var s stringfmt.Scan(&s)var ans int = 1e9for i := 0; i <len(s); i++ {if s[i] == 'c'{var cnt int = 0for j := i; j < len(s); j++ {if s[j] == 'w' {cnt++;}if cnt == 2 {ans = min(ans, j-i+1)}}}}if ans == int(1e9) {fmt.Println(-1)} else {fmt.Println(ans)}}