結果
問題 | No.2073 Concon Substrings (Swap Version) |
ユーザー |
|
提出日時 | 2023-01-10 23:52:27 |
言語 | Go (1.23.4) |
結果 |
WA
|
実行時間 | - |
コード長 | 849 bytes |
コンパイル時間 | 10,561 ms |
コンパイル使用メモリ | 239,924 KB |
実行使用メモリ | 6,824 KB |
最終ジャッジ日時 | 2024-12-21 12:42:11 |
合計ジャッジ時間 | 11,968 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 5 |
other | AC * 10 WA * 27 |
ソースコード
package mainimport ("bufio""fmt""os""strconv")var sc = bufio.NewScanner(os.Stdin)func main() {sc.Buffer(make([]byte, 1000), 500000)sc.Split(bufio.ScanWords)n := nextInt()s := nextString()a := make([][]int, 3)for i := range a {a[i] = make([]int, 3)}for i := range s {if s[i] == 'c' {a[0][i%3]++}if s[i] == 'o' {a[1][i%3]++}if s[i] == 'n' {a[2][i%3]++}}ans := 0for i := range a {tmp := a[0][i]if a[1][(i+1)%3] < tmp {tmp = a[1][(i+1)%3]}if a[2][(i+2)%3] < tmp {tmp = a[2][(i+2)%3]}ans += tmpif ans == n {fmt.Println(n)return}}if ans == n {ans--}fmt.Println(ans)}func nextInt() int {sc.Scan()i, e := strconv.Atoi(sc.Text())if e != nil {panic(e)}return i}func nextString() string {sc.Scan()return sc.Text()}