結果

問題 No.672 最長AB列
ユーザー Mr.FukuMr.Fuku
提出日時 2018-07-08 22:05:34
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 293 bytes
コンパイル時間 1,580 ms
コンパイル使用メモリ 10,612 KB
実行使用メモリ 35,792 KB
最終ジャッジ日時 2023-09-22 08:13:53
合計ジャッジ時間 4,491 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
7,896 KB
testcase_01 AC 15 ms
7,780 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 AC 15 ms
7,900 KB
testcase_05 AC 15 ms
7,904 KB
testcase_06 AC 15 ms
7,900 KB
testcase_07 AC 15 ms
7,836 KB
testcase_08 AC 15 ms
7,780 KB
testcase_09 WA -
testcase_10 AC 165 ms
22,804 KB
testcase_11 AC 164 ms
22,876 KB
testcase_12 AC 151 ms
9,548 KB
testcase_13 AC 163 ms
9,584 KB
testcase_14 AC 155 ms
9,572 KB
testcase_15 AC 154 ms
9,596 KB
testcase_16 AC 157 ms
9,684 KB
testcase_17 AC 171 ms
22,624 KB
testcase_18 AC 154 ms
9,720 KB
権限があれば一括ダウンロードができます

ソースコード

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