結果

問題 No.672 最長AB列
ユーザー Mr.Fuku
提出日時 2018-07-08 22:05:34
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
WA  
実行時間 -
コード長 293 bytes
コンパイル時間 244 ms
コンパイル使用メモリ 12,544 KB
実行使用メモリ 38,392 KB
最終ジャッジ日時 2024-07-08 00:34:48
合計ジャッジ時間 3,547 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2 WA * 1
other AC * 14 WA * 2
権限があれば一括ダウンロードができます

ソースコード

diff #

lst = list(input())

max_length = 0
count_list = {0:-1}
count = 0

for i in range(len(lst)):
    if lst[i]=="A":
        count += 1
    else:
        count -= 1
    count_list.setdefault(count,i)
    max_length = max(max_length,i-count_list[count])

print(max_length if max_length > 1 else -1)
0