結果

問題 No.672 最長AB列
ユーザー tsuchinagatsuchinaga
提出日時 2019-03-06 08:57:28
言語 Go
(1.22.1)
結果
WA  
実行時間 -
コード長 615 bytes
コンパイル時間 12,795 ms
コンパイル使用メモリ 209,532 KB
実行使用メモリ 8,760 KB
最終ジャッジ日時 2023-09-05 19:03:43
合計ジャッジ時間 17,323 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
7,836 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 AC 2 ms
4,380 KB
testcase_07 WA -
testcase_08 AC 2 ms
4,376 KB
testcase_09 AC 1 ms
4,376 KB
testcase_10 WA -
testcase_11 TLE -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strings"
)

func main() {
	maxSize := 2 * int(math.Pow10(5))
	rdr := bufio.NewReaderSize(os.Stdin, maxSize)
	buf := make([]byte, 0, maxSize)
	for {
		l, p, _ := rdr.ReadLine()
		buf = append(buf, l...)
		if !p {
			break
		}
	}
	s := string(buf)

	sl := len(s)
	al := strings.Count(s, "A")
	bl := sl - al
	limit := int(math.Min(float64(al), float64(bl))) * 2
	max := 0
	for i := limit; i >= 2; i -= 2 {
		for j := 0; j < sl-i; j++ {
			if strings.Count(s[j:j+i], "A")*2 == i {
				max = i
				break
			}
		}

		if max > 0 {
			break
		}
	}
	fmt.Println(max)
}
0